I dont understand why this gives an errror, it seems to work .
package com.codegym.task.task07.task0728;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
/*
In decreasing order
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int[] array = new int[20];
for (int i = 0; i < 20; i++) {
array[i] = Integer.parseInt(reader.readLine());
}
sort(array);
for (int x : array) {
System.out.println(x);
}
}
public static void sort(int[] array) {
//write your code here
Arrays.sort(array);
// let us print all the elements available in list
System.out.println("The sorted int array is:");
for (int i = 0; i < array.length; i++) {
int number = array[i];
int left = 0;
int right = array.length - 1;
while( left < right ) {
// swap the values at the left and right indices
int temp = array[left];
array[left] = array[right];
array[right] = temp;
// move the left and right index pointers in toward the center
left++;
right--;
}
return;
}
}
}