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.
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();
}
}
Comments
Leave a comment