Skip to content

Instantly share code, notes, and snippets.

@learncsdesign
Last active May 1, 2022 03:42
Show Gist options
  • Save learncsdesign/7c3615b0b31d6d23020fda49f79dab19 to your computer and use it in GitHub Desktop.
Save learncsdesign/7c3615b0b31d6d23020fda49f79dab19 to your computer and use it in GitHub Desktop.
package com.learncsdesign;
import java.util.PriorityQueue;
import java.util.Queue;
public class MyPriorityQueue {
public static void main(String[] args) {
Queue<String> animals = new PriorityQueue<>();
/* The elements of the priority queue are ordered
* according to their natural ordering,
* or by a Comparator provided at queue construction time
*/
animals.add("Panda");
animals.add("Deer");
animals.add("Monkey");
for (String animal : animals) {
System.out.println(animal);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment