// Yazzy Latif // TA: Grace Hopper // CSE 142 // Containing a few example of how to interact with ArrayLists. import java.util.*; public class ArrayListMethods { // array vs arraylist /* String[] --> ArrayList arr[i] --> list.get(i) arr.length --> list.size() arr[i] = "hello" --> list.set(i, "value"); list.add("new value"); // appends this value to the end of // my list */ public static void main(String[] args) { ArrayList list = new ArrayList(); list.add("ayo"); list.add("hey"); list.add("hi"); list.add("yo"); list.add("cya"); // removes all even lengthed words from list for (int i = list.size() - 1; i >= 0; i--) { String word = list.get(i); if (word.length() % 2 == 0) { list.remove(i); } } System.out.println(list); } }