011:在main方法中,定义一个长度为5的int类型数组并赋值,
打印输出数组的长度,并遍历输出每个元素的值。
package com.ifxp.homework_011;
public class Homework_011 {
public static void main(String[] args) {
int[] buzhidao = new int[5];
for (int i = 0; i < buzhidao.length; i++) {
System.out.println(buzhidao[i]);
}
System.out.println("~~~~~~~~~~~~~~~~~~~");
buzhidao[0] = 10;
buzhidao[1] = 20;
buzhidao[2] = 30;
buzhidao[3] = 40;
buzhidao[4] = 50;
System.out.println(buzhidao[0]);
System.out.println(buzhidao[1]);
System.out.println(buzhidao[2]);
System.out.println(buzhidao[3]);
System.out.println(buzhidao[4]);
}
}
012:定义长度为5的int类型数组并使用随机数赋值,求出所有元素之和
package com.ifxp.homework_012;
import java.util.Ar