可变参数
package com.zishi.method;
public class Demo04 {
public static void main(String[] args) {
printMax(1,2,3,4,5,6,7);
printMax(new double[]{1,2,3,45});
}
// 可变参数
public static void printMax(double... numbers){
if(numbers.length==0){
System.out.println("No argument");
return;
}
double result = numbers[0];
//排序
for(int i=1; i < numbers.length ; i++){
if(numbers[i] > result){
result = numbers[i];
}
}
System.out.println("The max value id "+result);
}
}