import java.util.*; // ArrayList class is in java.util public class ArrayListFun { public static void main(String[] args) { // Here, the type of the variable words is "ArrayList" // In other words, "an ArrayList of String objects" ArrayList list = new ArrayList(); // add some elements to the ArrayList list.add("hello"); String x = new String("world"); list.add(x); list.add("this is fun"); // print out list System.out.println("list = " + list); // print out the zeroth and second element System.out.println("0th element = " + list.get(0) + ", 2nd element = " + list.get(2)); // add something to middle list.add(1, "middle value"); System.out.println("list = " + list); // remove some things list.remove(1); list.remove(2); System.out.println("list = " + list); // ask how long the list is System.out.println("list size: " + list.size()); } }