Java可变参数
2020-12-27 10:27
标签:max value pre turn oid out 参数 main void inf Java可变参数 标签:max value pre turn oid out 参数 main void inf 原文地址:https://www.cnblogs.com/acg-lbj/p/13032886.html public static void main(String[] args) {
printmax(34,3,2,5,67);
printmax(new double[]{1,2,3});
}
public static void printmax(double...number){
if (number.length==0){
System.out.println("No argument passed");
return;
}
double result=number[0];
for (int i = 0; i
if (number[i]>result){
result=number[i];
}
}
System.out.println("the max value is "+result);
}
}
下一篇:python转义引起的错误