完整问题:创建一个将整数数组(任意大小)的内容输出到屏幕的方法。
我的尝试(不正确):
包实用5;
公共类 Part1_7 {
/**
* constant referring to array length
*/
public final static int ARRAY_LENGTH= 10;
/**
* A method that outputs the contents of
* an array of integers (of any size) to screen
*/
public static void main(String[] args) {
int[] contents= new int [ARRAY_LENGTH];
for (int counter=0; counter<contents.length; counter++){
//set array contents
contents[counter]= 1;
//print array contents
System.out.println(contents[counter]);
}
}
}