String... to 可变参数的使用

 1 public class testMail {
 2 
 3     public static void fun(int... x) {
 4           for(int i = 0;i < x.length;i++) {  
 5               System.out.print(x[i] + ",");  
 6               } 
 7           } 
 8         public static void main(String args[]) throws Exception{ 
 9             fun(5);  System.out.println("");  
10             fun(5,6);  System.out.println("");
11             fun(5,6,7); 
12             }
13 }

输出:
5,

5,6,

5,6,7,

posted on 2015-09-10 09:35  百东  阅读(314)  评论(0编辑  收藏  举报

导航