enterQueue, leaveQueue

korex

New Member
Does anyone have references to examples for enterQueue() and leaveQueue() for the Queue class in Java? I'm trying to do an assignment demonstrating the actions of enterQueue() and leaveQueue() but I can't seem to find anything in the API.. I already did Peek, Poll, and size. That code is attached here, even though I suppose it's not really relevant.\[code\]Stack st = new Stack(); Queue<String> q = new LinkedList<String>(); String element; st.push("A"); st.push("B"); System.out.println("\fInitial Stack contents: "+st); q.addAll(st); st.clear(); Iterator itr = q.iterator(); System.out.println("\nInitial Queue size: "+q.size()); System.out.println("It contains "+q+" while the stack is now "+st+"\n"); while(itr.hasNext()) { String iteratorValue = http://stackoverflow.com/questions/15670121/(String)itr.next(); System.out.println("Next in queue: "+iteratorValue); } //Peek : Look at value, don't remove it System.out.println("\nQueue Peek: "+q.peek()); // Poll : Remove first value from queue element = q.poll(); System.out.println("\nQueue Poll: "+element); System.out.println("\nQueue Size now: "+q.size()); System.out.println("Queue remainder: "+q);\[/code\]
 
Back
Top