int arr[] = new int[10]; for(int i=0;i<10;i++){ arr[i]=s.nextInt(); } Arrays.sort(arr); System.out.println(" "+Arrays.toString(arr)); my input is :
98 7 6 5 4 32 14 5 1 7
my output is :
[1, 4, 5, 5, 6, 7, 7, 14, 32, 98]
but i want to print my output as sorted number only but not with [ ] and commas what would be the required solution
System.out.println(Stream.of(arr).sorted( ).map( String::valueOf ).collect( Collectors.joining( " " ) ));