The following example demonstrates how to create An ArrayList of Week Days in Java.

The ArrayList represents a dynamically growing array in Java. The following example uses a generic ArrayList class. It creates an ArrayList of strings. As can be seen, we use the add() method to add an element to the list. Also, the ArrayList preserves the insertion order. In other words, the elements of the ArrayList are arranged in the order of insertion. In order to display the elements of the ArrayList, we use an object of the Iterator class. Its next() method returns the next element in the list until the hasNext() method returns a false value.

import java.util.*;
public class WeekList
{
	public static void main(String[] args)
	{
		ArrayList<String> weekList=new ArrayList<String>();
		weekList.add("Sunday");
		weekList.add("Monday");
		weekList.add("Tuesday");
		weekList.add("Wednesday");
		weekList.add("Thursday");
		weekList.add("Friday");
		weekList.add("Saturday");

		Iterator weekIt=weekList.iterator();
		while(weekIt.hasNext())
		{
			System.out.println("Week Day: "+weekIt.next());
		}
	}
}

Output

A Program to Create An ArrayList of Week Days in Java
A Program to Create An ArrayList of Week Days in Java

Further Reading

30+ Basic Java Programs

Java Practice Exercise

programmingempire

Princites