public static void main(String[] args) throws ParseException, UnsupportedEncodingException {
/* For-Each循环也叫增强型的for循环,或者叫foreach循环。
For-Each循环是JDK5.0的新特性(其他新特性比如泛型、自动装箱等)。
For-Each循环的加入简化了集合的遍历。
For-Each循环的缺点:丢掉了索引信息。
当遍历集合或数组时,如果需要访问集合或数组的下标,
那么最好使用旧式的方式来实现循环或遍历,
而不要使用增强的for循环,因为它丢失了下标信息。*/
int [] arr = new int []{1,2,3,4,5,6,7,8,9,10};
//普通遍历
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
//增强型的for循环
for (int i : arr) {
System.out.println(i);
}
}