[Solved] I have two error codes in Java I am not familiar with [duplicate]


You have to change the name of your class because the class Arrays is already part of the java API and that would create confusion

import java.util.Arrays;

public class OtherNameThanArrays {

    public static void main(String[] args) {

        int[] numbers = new int[5];

        numbers[0] = 31;
        numbers[1] = 88;
        numbers[2] = 11;
        numbers[3] = 73;
        numbers[4] = 45;

        int[] numbers2 = {99, 1, 2, 3, 4};

        Arrays.sort(numbers);
        Arrays.sort(numbers2);

        System.out.println(Arrays.toString(numbers));
        System.out.println(Arrays.toString(numbers2));
    }


}

And if I can allow myself here is a second approach to sort a list differently than a table :

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class OtherNameThanArrays {

    public static void main(String[] args) {

        ArrayList<Integer> numbers1 = new ArrayList<>(Arrays.asList(31,88,11,73,45));
        ArrayList<Integer> numbers2 = new ArrayList<>(Arrays.asList(99,1,2,3,4));
        Collections.sort(numbers1);
        Collections.sort(numbers2);
        System.out.println(numbers1);
        System.out.println(numbers2);

    }
}

Console output for both approach:

[11, 31, 45, 73, 88]
[1, 2, 3, 4, 99]

0

solved I have two error codes in Java I am not familiar with [duplicate]