日期:2014-05-20 浏览次数:20675 次
public static void pp(int b){ System.out.println("hellow!"); } public static void pp(int... b){ System.out.println("hellow sec!"); }
public class VarArgsTest { public static void main(String[] args) { m1(); m1("one"); m1("one","two"); //m1("one","two","three");//报错,因为系统不知道调用哪个方法... } public static void m1(String s1,String s2){ System.out.println("m1(String s1,String s2)"); } public static void m1(){ System.out.println("m1()"); } public static void m1(String s){ System.out.println("m1(String s)"); } public static void m1(String s,String... str){ System.out.println("m1(String s1,String... str)"); } public static void m1(String... str){ System.out.println("m1(String... str)"); } }