PriorityQueue

Run Settings
LanguageJava
Language Version
Run Command
import java.util.*; class Main { public static void main(String[] args) { Queue<Integer> queue = new PriorityQueue<>((a, b) -> { if(a > b) return 1; else if(a < b) return -1; else return 0; }); queue.add(5); System.out.println(queue); queue.add(3); System.out.println(queue); queue.add(4); System.out.println(queue); queue.add(6); System.out.println(queue); queue.add(7); System.out.println(queue); queue.add(2); System.out.println(queue); queue.add(3); System.out.println(queue); } }
Editor Settings
Theme
Key bindings
Full width
Lines