1

One way to be more concise is to use the Stream.sorted() method right in the stream: public static int[] sortedSquares(int[] arr) { arr = Arrays.stream(arr).map(i -> i * i).sorted().toArray(); return arr; }


Only top voted, non community-wiki answers of a minimum length are eligible