package method;
public class Demo_04 {
public static void main(String[] args) {
//调用可变参数
printMax(10,20.5,30,5,2.1);
}
//打印最大的数,可变参数方法
public static void printMax(double...num){
if (num.length==0){
System.out.println("No argument passed");
return;
}
double result = num[0];
//排序
for (int i = 0; i < num.length; i++) {
if(num[i]>result){
result = num[i];
}
}
System.out.println("The max value is"+ result);
}
}