Interface or Concrete class?
This is my understanding for good Java programming. Can you let me know if it's correct or not please?
In a class, then it's okay to use a concrete class. For example
ArrayList<Car> cars;
In a parameter input of a method, then it's recommended to use an interface for flexibility. For example
public void getCars(List<Car> cars) {
}
or
public void getCars(Collection<Car> cars) {
}
instead of
public void getCars(ArrayList<Car> cars) {
}
Am I correct?