Answers for "how does 2b2t make queue work"

0

queue 2

Queue<String> queue = new LinkedList<>();

queue.add("element 0");
queue.add("element 1");
queue.add("element 2");

//access via Iterator
Iterator<String> iterator = queue.iterator();
while(iterator.hasNext(){
  String element = iterator.next();
}

//access via new for-loop
for(String element : queue) {
    //do something with each element
}
Posted by: Guest on August-04-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language