public class MyQueue<T extends Tree> implements Queue<T> {
public T element() {
... your code to return an element goes here ...
}
public boolean offer(T element) {
... your code to accept a submission offer goes here ...
}
... etc ...
}
java.util.Queue<String> queue = new LinkedList<>();
queue.offer("Hello");
queue.offer("StackOverFlow");
queue.offer("User");
System.out.println(queue.peek());
while (queue.size() > 0){
System.out.println(queue.remove() + " ");
}
//Since Queue is empty now so this will return NULL
System.out.println(queue.peek());