Array List Lesson
import java.util.Arrays;
import java.util.ArrayList;
public class arrayListLesson {
public static void main(String[] args) {
ArrayList<String> myArray = new ArrayList<>(Arrays.asList("Index1", "Index2", "Index3", "Index4"));
System.out.println(myArray); // print entire list
System.out.println(myArray.get(1)); // print index 1 (starting at 0 of course)
myArray.add("Index5");
System.out.println(myArray);
if(myArray.contains("Index4")) { // .contains checks if an index exists
System.out.println("Index 4 exists.");
}
}
}
arrayListLesson.main(null);