Java #35: How to use the For Each Function to Print

———-Full Source Code———–
//Programmer: Akinwale Owi
//Company: Dagba Computers
//Program Purpose: Print ArrayList Values using the For Each Function

package dagbacomputers;

* @author Akin

import java.util.*;

public class DagbaComputers {

* @param args the command line arguments
public static void main(String[] args)
//Creaation of ArrayList we’ll be Printing from
ArrayListcities = new ArrayList();

//Adding items to list
cities.add(“New York”);

//For Each Loop to Print out all values
for (String d: cities)
System.out.println(d);//Printing values
}//end of for

}//end of main
}//End of DagbaComputers Class

———-End of Program———


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s