基本for循环
Object[] array = {1, 2.5, "Hello"};
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
增强for循环 (也称为foreach循环):
Object[] array = {1, 2.5, "Hello"};
for (Object element : array) {
System.out.println(element);
}
使用`Arrays.stream()`方法
Object[] array = {1, 2.5, "Hello"};
array.stream().forEach(System.out::println);
使用迭代器
Object[] array = {1, 2.5, "Hello"};
Iterator