数组作为返回值
package 笔记编写代码;
import java.lang.reflect.Array;
import java.util.Arrays;
public class 数组返回值 {
public static void main(String[] args) {
int a = 10, b = 20, c = 30;
int[] result = sum_averager(a, b, c);
System.out.println("数组的返回值为" + Arrays.toString(result));
System.out.println("sum=" + result[0]);
System.out.println("averager=" + result[1]);
}
public static int[] sum_averager(int a, int b, int c) {
int sum = a + b + c;
int averager = sum / 3;
/*int []array=new int[2];
array[0]=sum;
array[1]=averager;
return array;*/
int[] array = {sum, averager};
return array;
}
}