有如下一个String数组
String[] array = {"a", "b", "c", "d", "e"};

1.根据下标遍历

for(int i = 0; i < 5; i++){
}

2.foreach遍历

for(String x : array){

3.迭代器遍历

List list = Arrays.asList(array);

4.stream遍历

Arrays.asList(array).stream().forEach(x -> System.out.println(x));

也可以这样写:

Arrays.asList(array).stream().forEach(System.out::println);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2021-06-15
猜你喜欢
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2021-10-17
  • 2021-12-06
相关资源
相似解决方案