In Java 8, a better and more concise approach might be:
double[] arr = {13.6, 7.2, 6.02, 45.8, 21.09, 9.12, 2.53, 100.4}; Double[] boxedarr = Arrays.stream( arr ).boxed().toArray( Double[]::new ); Arrays.sort(boxedarr, Collections.reverseOrder()); System.out.println(Arrays.toString(boxedarr));
This will give an inverse array and be more presentable.
Initial data: [13.6, 7.2, 6.02, 45.8, 21.09, 9.12, 2.53, 100.4]
Yield: [100.4, 45.8, 21.09, 13.6, 9.12, 7.2, 6.02, 2.53]
alamshahbaz16497 Feb 26 '18 at 20:56 2018-02-26 20:56
source share