I studied polymorphism and understand that it can do dynamic method binding like below.
Assuming that class Animal is abstract class.
public class An
By declaring and using myList
as a Collection, you are hiding the implementation choice you are making (in this case, that it is represented as an ArrayList). In general, this means that any things that depend on your piece of code will only rely on myList behaving as a Collection, not as an ArrayList in particular. That way if you decide to represent it as something else later on (a Set? A Linked List?) for whatever reason, you don't break anything else.