How to get an iterator over array of string in Java

1 Answer

0 votes
import java.util.Arrays;
import java.util.Iterator;
 
public class MyClass
{
    public static void main(String[] args)
    {
        String[] arr = { "java", "c", "c++", "c#", "python" };
 
        Iterator<String> iterator = Arrays.asList(arr).iterator();
 
        iterator.forEachRemaining(System.out::println);
    }
}



/*
run:

java
c
c++
c#
python

*/

 



answered Mar 18, 2023 by avibootz

Related questions

1 answer 111 views
3 answers 153 views
1 answer 122 views
122 views asked Mar 13, 2021 by avibootz
1 answer 145 views
...