Java 19-方法 参数
1、参数列表和返回值
public static void function(int num){//形参
System.out.println("传入的参数是:"+num);
}
public static void main(String[] args) {
function(3);//实参
}
public static void function3(int[] scores){
int sum = 0;
for (int x:scores){
sum = sum+x;
}
double avg = sum*1.0/(scores.length);
System.out.println(avg);
}
public static void main(String[] args) {
int [] ss = {89,90,91,82,98};
function3(ss);
}