java 不定参数使用示例

public class javaTest { public static void test(String ...strings){ for(String str: strings){ System.out.print(str + " "); } System.out.println(); } public static void main(String[] args){ test("a", "b", "c", "ddd"); test("a"); test("aaa", "aaadfd"); } }

 

输出结果


a b c ddd
a
aaa aaadfd

你可能感兴趣的:(java,c,String,Class)