Sunday, 18 December 2022

Java collections - QUEUE

 Write a program using queue data structure , add the three aplhabates a,b,c and remove the b .



import java.util.*;

public class simplequeue {

    public static void main(String args[])
    {
        Queue<String> pq = new PriorityQueue<>();

        pq.add("a");
        pq.add("b");
        pq.add("c");
        System.out.println(pq);
        pq.remove("b");
        System.out.println(pq);

    }
}



outptut: 
[a, b, c]
[a, c]

No comments:

Post a Comment

GitHub Most Imp Command For Every Developer Learn:

 Top Command for GitHub:  1) git clone 2) git init and git status   3) git add file name  or git add .  4) git commit -m message  5) git rem...