一般的for循环写法:
遍历数组
for(int i = 0; i < MaxnNum; i++)
遍历Collection对象
for (Iterator itr = List.iterator(); itr.hasNext();) { itr.next();}
另一种写法
遍历数组
for(int i: integers)
遍历Collection对象
String[] strings = {"A", "B", "C", "D"}; Collection list = java.util.Arrays.asList(strings); for (Object str : list) { System.out.println(str); }
时间: 2024-10-06 06:05:58