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 338 views
1 answer 311 views
1 answer 350 views
2 answers 396 views
...