Answer to Question #318383 in Java | JSP | JSF for Komal

Question #318383

Implement your own version of queue data structure using java with OOPs principles mentioned functionalities: enqueue, Dequeue , peek, contains, size, center, sort reverse, iterator, traverse/print.

Use of similar data structures already present in the language/framework is not allowed.


1
Expert's answer
2022-03-27T13:17:36-0400
import java.util.LinkedList;
import java.util.Queue;

public class Main {


    public static void main(String[] args) {

        Queue queue = new LinkedList();


        queue.add("1");
        queue.add("2");
        queue.add("3");
        queue.add("4");

        queue.remove();


        System.out.println(queue.peek());

        while (queue.size() > 0){
            System.out.println(queue.poll());
        }

        System.out.println(queue.size());

        queue.stream().sorted();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS