public class t1 {
public static double avg(double... arr){
double sum = 0;
for (double i:arr) {
if (i<0){
throw new RuntimeException("参数为负数");
}sum = sum+i;
}
return sum/arr.length;
}
public static void main(String[] args) {
double s = avg(2,6,5,4);
System.out.println(s);
}
}