Integer.MAX_VALUE+1=Integer.MIN_VALUE
java int类整数的最大值是2的31次方-1=2147483648 - 1 = 2147483647
即 Integer.MAX_VALUE;
JAVA的int类整数的最大值等于int类整数的最小值-1
Integer.MAX_VALUE+1=Integer.MIN_VALUE=-2147483648
常用于比较大小
若比较找最小则定义min为Integer.MAX_VALUE
若比较找最大则定义max= Integer.MIN_VALUE

例子:
2020省赛真题:成绩分析

package test_2;
import java.util.Scanner;
public class Test_10 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
double sum = 0;
for (int i = 0; i < n; i++) {
int t = scanner.nextInt();
min = Math.min(min, t);
max = Math.max(max, t);
sum += t;
}
System.out.println(max + "\n" + min + "\n" + String.format("%.2f", sum / n));
}
}