4.) Priority Queue (basic)
Write a program to get size of the queue.
import java.util.PriorityQueue;
public class PriorityQueueSizeExample {
public static void main(String[] args) {
// Create a new priority queue
PriorityQueue<Integer> pq = new PriorityQueue<>();
// Add some elements to the priority queue
pq.add(10);
pq.add(20);
pq.add(30);
// Get the size of the priority queue
int size = pq.size();
// Print the size of the priority queue
System.out.println("Priority queue size: " + size);
}
}
Comments
Post a Comment