Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

enhanced for loop with arraylist

import java.util.* ;
public class IteratorExampleTwo
{
  public static void main ( String[] args)
  {
    ArrayList<String> names = new ArrayList<String>();

    names.add( "Amy" );    names.add( "Bob" ); 
    names.add( "Chris" );  names.add( "Deb" ); 
    names.add( "Elaine" ); names.add( "Frank" );
    names.add( "Gail" );   names.add( "Hal" );
    
    for ( String nm : names ) 
      System.out.println( nm );
  }
}
Source by learn.saylor.org #
 
PREVIOUS NEXT
Tagged: #enhanced #loop #arraylist
ADD COMMENT
Topic
Name
2+1 =