You have been declaring variables as ArrayList<String>. But you can also declare them as List<String>:
import java.util.List;
List<String> names = new ArrayList<>();
List is an interface that defines the methods every list must have: .add(), .get(), .remove(), .size(), and so on. ArrayList is one class that implements this interface. Another is LinkedList.
Why use List instead of ArrayList in the declaration? It lets you swap implementations later without changing the rest of your code. If LinkedList fits better, you only change the new line. Every method call stays the same.
This idea of programming to an interface instead of a concrete class is a pattern you will see again in the OOP sections.