public class MaxMin{ public static void main(String[] args) { int[] arr = new int[6]; Scanner input = new Scanner(System.in); for (int i = 0; i < arr.length; i++) { System.out.println("请输入第" + (i + 1) + "个数字:"); int number = input.nextInt(); arr[i] = number; } int sum = 0, min = arr[0], max = min; for (int i = 0; i < arr.length; i++) { sum += arr[i]; if (min > arr[i]) { min = arr[i]; } if (max < arr[i]) { max = arr[i]; } } System.out.println("最大值:" + max); System.out.println("最小值:" + min); }}