The .remove() method deletes an element from the list. You can remove by index:
colors.remove(0);
This removes the element at index and shifts all remaining elements left by one position. The list shrinks by .
You can also remove by value:
colors.remove("blue");
This searches for the first occurrence of "blue" and removes it. If the value is not in the list, nothing happens.
Both forms return a value. The index version returns the removed element. The object version returns true if it found and removed the element, false otherwise. Be careful with ArrayList<Integer> because remove(1) removes at index , not the value . I'll explain that trap in the next quiz.