Possible Duplicates:
What does it mean to program to a interface?
Interface List - java
Hey there. I've been asked to use an the interface list in a couple of classes. My teacher says that this is to make it easier in the future to exchange an implementation. I've been asked to replace ArrayList by List wherever possible but am still not entirely sure what this means. I think I understand what an interface is but am not sure how to go ahead with the changes.
So for instance, this is the first part of one of the classes that I am supposed to modify all of the ArrayList bits with List. Any help is appreciated
public class Simulator
{
// Constants representing configuration information for the simulation.
// The default width for the grid.
private static final int DEFAULT_WIDTH = 70;
// The default depth of the grid.
private static final int DEFAULT_DEPTH = 40;
// List of animals in the field.
private ArrayList<Animal> animals;