提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
创建数组并分配给另一个数组
public class Main {/** N o w J a v a . c o m 提 供 **/ public static void main(String[] arguments) { int[] myArray = { 1_900_000, 1_700_000, 1_700_000 }; int[] my = new int[myArray.length]; int[] total = new int[myArray.length]; int average; my[0] = 1_900_000; my[1] = 1_800_000; my[2] = 1_750_000; total[0] = myArray[0] + my[0]; total[1] = myArray[1] + my[1]; total[2] = myArray[2] + my[2];/**来自 N o w J a v a . c o m**/ average = (total[0] + total[1] + total[2]) / 3; System.out.print("2009 production: "); System.out.format("%,d%n", total[0]); System.out.print("2010 production: "); System.out.format("%,d%n", total[1]); System.out.print("2011 production: ");