文章目录
1、for循环遍历:
2、forEach循环(增强for循环):
3、while循环 或者 do while循环:
4、利用Arrays工具类当中的toString():
int [] array = {
1,2,3,4,5};
System.out.print(Arrays.toString(array));
5、流式遍历:
int[] arr = {
1, 2, 3, 4, 5};
Arrays.stream(arr).forEach(num -> System.out.println(num));
6、使用Arrays.asList()和forEach()方法进行遍历:
Integer[] arr = {
1, 2, 3, 4, 5};
List<Integer> list = Arrays.asList(arr);
list.forEach(num -> System.out.println(num));