android - 为什么 PriorityQueue 在 Android 中需要 API 24

标签 android priority-queue

PriorityQueue 是在 Java 1.5 中添加的

new PriorityQueue()在 Android 中启用,但是

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

需要 API 24。为什么?

最佳答案

因为 PriorityQueue(Comparator)在 API 级别 24 中将构造函数添加到 SDK。在 JDK 中,该构造函数是在 Java 8 中添加的。

为了与早期的 API 级别兼容,您可以使用 PriorityQueue(int,Comparator)自 API 级别 1 以来就存在。

关于android - 为什么 PriorityQueue 在 Android 中需要 API 24,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47301031/

相关文章:

Android 多行数字编辑文本

java - 如何获取 "-"(破折号)前后的文本

android - 当我的 Activity 弹出对话框时,不会调用我的 Activity 的 onBackPressed()

c++ - 如何将 priority_queue 与类实例的非静态比较方法一起使用?

java - 从优先队列中删除 Java

Android的SoundPool不播放任何声音

c - C 中的优先级队列实现 - 将字符更改为整数

java - java优先级队列中的成员函数返回但不删除指定值?

c++ - 优先级队列和堆之间的区别

android - 在 Retrofit 中使用 Call Enqueue 函数