增强for循环赋值
增强for循环赋值
代码如下:
double[] testList01 = new double[5];
java.util.Scanner sc = new java.util.Scanner(System.in);
System.out.println("请输入 " + testList01.length + " 个值");
for (int i = 0; i < testList01.length; i++) {
testList01[i] = sc.nextDouble();
}
//
double[] testList02 = new double[5];
// for-each循环(for-each loop)
//将数组testList01的内容赋值给testList02
for (int i = 0; i < testList01.length; i++) {
testList02[i] = testList01[i];
}
for (int i = 0; i < testList02.length; i++) {
System.out.println("testList02的第"+ i + "个元素是:" +testList02[i]);
}
希望有所帮助
只相信苦尽甘来