码迷,mamicode.com
首页 > 其他好文 > 详细

可变参数

时间:2014-07-06 17:11:31      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:使用   for   ar   c   public   数组   

/**************可变参数的使用*****************/
 //注意:可变参数一定要放在参数列表的最后,使用时是作为数组来进行操作
// public static void main(String[] args) {
//  method("总和为:",10,50,20);
//  method("总和为:",10,50,20,20);
//  method("总和为:",10,50,20,20,60);
// }

// //int... numbers就是可变参数
// public static void method(String str,int... numbers){
//  int total = 0;
//  for (int num : numbers) {
//   total += num;
//  }
//  System.out.println(str+total);
// }

可变参数,布布扣,bubuko.com

可变参数

标签:使用   for   ar   c   public   数组   

原文地址:http://www.cnblogs.com/danmao/p/3825266.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!