Welcome to the Treehouse Community
Looking to learn something new?
I didn't understand something that Craig said.
At 0:40, in this video Craig Dennis says that "we always wanna return the list interface not the implementation because in the future we could change the implementation if we wanted to and we wouldn't break code the code that uses this method." What does this exactly mean? I didn't understand a word of it. Please explain.
In the example:
List<String> results = new ArrayList<>();
List<String> is the interface and ArrayList<>() is the implementation. In this case you want to return List<String> because that allows you to implement it into a different class like a HashSet instead of a ArrayList, for example.