在方法声明中,在指定参数类型后加一个省略号(...)
package com.kuangshen.method; public class Demo04 { public static void main(String[] args) { Demo04 demo04 = new Demo04(); demo04.test(1,2); } public void method(){} //IDEA中 ctrl + D 复制行 public void test(int x,int...i){ System.out.println(x+i[0]); } }
原文:https://www.cnblogs.com/cjybarcode/p/13380740.html