MyClass.java
 

import java.util.ArrayList;

public class MyClass { 
  public static void main(String[] args) { 
    ArrayList cars = new ArrayList();
    cars.add("Volvo");
    cars.add("BMW");
    cars.add("Ford");
    cars.add("Mazda");
    for (String i : cars) {
      System.out.println(i);
    }
  } 
}


Result:
Volvo
BMW
Ford
Mazda