-
-
Save learncsdesign/7c3615b0b31d6d23020fda49f79dab19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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