package prjarrays;

import java.io.*;
import java.util.Arrays;
import java.util.Collections;

class BubbleSorting
{
    public static void main(String[] args)throws IOException
    {
        BufferedReader a = new BufferedReader(new InputStreamReader(System.in));
        int []num = {54,92,04,98};
->      Arrays.sort(num, Collections.reverseOrder());
        for(int str : num)
        {
            System.out.print(str + " ");
        }
    }
}

cannot find symbol method sort(int[],java.util.Comparator<java.lang.Object>)

why do i get this error?..

Recommended Answers

Like it says, there is no sort method in the Arrays class that takes an int[] and a Comparator as parameters. Why did you think that there was such a method?

Jump to Post

All 2 Replies

Like it says, there is no sort method in the Arrays class that takes an int[] and a Comparator as parameters. Why did you think that there was such a method?

Beacuse that method signature does not exist. Check the API.

You could use an Integer[] array and it would work.

Edit: Bizarre crosspost with James. Thread had no reply when I posted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.