Java可变参数/可变长参数 传递的参数不确定长度,是变长的参数,例如小例子: package demo; public class Demo { public static int sum(int n, int... nums) { for (int i = 0; i < nums.length; i++) { n = n + nums[i]; } return n; } public static void main(String[] args) { int s1 = sum(1, 2);…