Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why PriorityQueue requires API 24 in Android

PriorityQueue was added in Java 1.5

new PriorityQueue()is enabled in Android, but

  new PriorityQueue(new Comparator() {
        @Override
        public int compare(Object o1, Object o2) {
            return 0;
        }
    });

requires API 24. Why?

like image 689
鸡蛋花树 Avatar asked Aug 31 '25 03:08

鸡蛋花树


1 Answers

Because PriorityQueue(Comparator) constructor was added to the SDK in API level 24. In JDK, that constructor was added in Java 8.

For compatibility with earlier API levels, you can use PriorityQueue(int,Comparator) that has been there since API level 1.

like image 173
laalto Avatar answered Sep 02 '25 16:09

laalto