I know, we need to use fortmat() method while formatting the output. Here is my below code:
int arr[] = { 38, 27, 43, 3, 9, 82, 10 };
Arrays.stream(arr).forEach(s -> System.out.format("%2d", s));
//output 382743 3 98210
If i use below code:
Arrays.stream(arr).forEach(s -> System.out.format("%3d", s));
//output 38 27 43 3 9 82 10
I want to print the output only with one space between the next value. something like 38 27 43 3 9 82 10