Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Iterating The Queue Elements

import java.util.*;
public class Main {
   public static void main(String[] args) {
     //declare a Queue  
    Queue LL_queue = new LinkedList();
    //initialize the Queue
    LL_queue.add("Value-0");
    LL_queue.add("Value-1");
    LL_queue.add("Value-2");
    LL_queue.add("Value-3");
    //traverse the Queue using Iterator
    System.out.println("The Queue elements through iterator:");
    Iterator iterator = LL_queue.iterator();
    while(iterator.hasNext()){
        String element = (String) iterator.next();
        System.out.print(element + " ");
    }
    System.out.println("

The Queue elements using for loop:");
    //use new for loop to traverse the Queue
    for(Object object : LL_queue) {
        String element = (String) object;
        System.out.print(element + " ");
    }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: class c { public static void main(string[] args){ system.out.println("hello"+args[0]);}} output 
Java :: how to add a singleton hashset in java 
Java :: action listener for button to close window java 
Java :: java equals on recursive apache commons 
Java :: programa que convierete un archi de c a java 
Java :: Android java parse class name via intent 
Java :: data structure in java 
Java :: use flatpickr in javascripot 
Java :: ExpandableLayout in android 
Java :: java application security best practices 
Java :: Kotlin const to Java 
Java :: java reverse a word 
Java :: java program operations by classes and objects 
Java :: DMC5 performace mod 
Java :: h2 database allow remote database creation 
Java :: how to import a self written class in java 
Java :: string.equals 
Java :: java to run colored lines 
Java :: difference between string vs stringbuffer 
Java :: UIManager.setLookAndFeel Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke because "style" is null 
Java :: Error: Unable to export or encrypt the private key java.lang.NullPointerException 
Java :: print out list of letters a to z java 
Java :: java importieren 
Java :: get time zone from co-ordinates java 
Java :: data input stream using while loop 
Java :: what are construtcor java 
Java :: password = sdf345 password.isalpha() java 
Java :: java list to jsonelement 
Java :: public class MyClass { public static void main(String[] args) { System.out.println("Hello World"); } } 
Java :: android gradle plugin requires java 11 problem 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =