这里需要一点建议, 我想要代码 创建一个包含任意六个名字的字符串数组。 使用增强的for循环数组 在这里,在打印的每个名字是我:字符串数组与增强for循环
public class names {
private static String[] arrayString;
private static String[] names;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String[][]firstnames={
{"John", "Mary", "Harry", "Ray", "Sean", "Matthew" },
};
for (int row=0;row<firstnames.length;row++){
for(int col=0; col<firstnames[row].length; col++){
System.out.print(firstnames[row][col]+ " ");
System.out.println();
}
}
}
}
我被告知,你已经使用固定的值上的拉环,而不是数组的长度条件。
这是更好地使用数组的长度为维护等
我已经花了很长时间试图找出哪里出了问题,据我可以看到我已经回答了这个问题。有人能指引我朝着正确的方向吗?
_我被告知你已经使用固定值的循环条件,而不是array_的长度告诉你这是在说谎 –
你是否有任何错误消息被抛出,或者你只是问你是否应该使用固定值? – Simon
我认为他们试图告诉你的是,这不是一个增强的for循环。 https://blogs.oracle.com/CoreJavaTechTips/entry/using_enhanced_for_loops_with –