How to print array using stream in Java

1 Answer

0 votes
import java.util.Arrays; 

public class MyClass {
    public static void main(String args[]) {
        int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
            
        Arrays.stream(arr).forEach(e->System.out.print(e + " ")); 
    }
}




/*
run:

1 2 3 4 5 6 7 8 9 10 

*/

 



answered Oct 1, 2019 by avibootz

Related questions

1 answer 238 views
1 answer 228 views
1 answer 276 views
2 answers 281 views
...