标签:new 一个 for change ram stat param double main
一个方法中只能指定一个可变参数,它必须是方法的最后一个参数。任何普通的参数必须在它之前声明。
public class ChangeableParam {
public static void main(String[] args) {
double[] arr = new double[]{12,34,55,66};
ChangeableParam changeableParam = new ChangeableParam();
changeableParam.testChangeableParam(99,arr);
}
//可变参数实质就是数组
public void testChangeableParam(int a,double...n){
System.out.println("普通参数:" + a);//99
System.out.println("可变参数:");
for (int i=0; i<n.length; i++)
System.out.print(n[i] + " ");//12.0 34.0 55.0 66.0
}
}
标签:new 一个 for change ram stat param double main
原文地址:https://www.cnblogs.com/dearjohn/p/14698024.html