代码如下:

package day05;

import java.util.Scanner;

/*
 * 键盘输入3个数字,求出最大值
 * */
public class ScannerMax {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入第一个数字:");
        int num1 = scanner.nextInt();
        System.out.print("请输入第二个数字:");
        int num2 = scanner.nextInt();
        System.out.print("请输入第三个数字:");
        int num3 = scanner.nextInt();
        int[] array = new int[]{num1, num2, num3};
        arrayMax(array);
    }

    public static void arrayMax(int[] array) {
        if (array.length != 0) {
            int maxValue = array[0];
            for (int i = 1; i < array.length; i++) {
                if (maxValue < array[i]) {
                    maxValue = array[i];
                }

            }
            System.out.println("最大值是:" + maxValue);
        } else {
            System.out.println("数组为空");
        }

    }
}