可变参数定义
public static void main(String[] args) {// 多参数方式传递System.out.println(max(1,3,5,3,6,1,2));// 数组方式传递System.out.println(max(new int[]{1,3,5,3,6,1,2}));
}static int max(int... nums){int max = Integer.MIN_VALUE;for (int num : nums) {if(num > max){max = num;}}return max;
}