Rendben, akkor jól sejtettem.
Közben hátha valakinek még jól jön, egy kis szemléltetés:
And it is. Here's a real-life example:
public void doSomething(List<String> list) {
// code to do sonething with 'list'
}
...
List<String> al = new ArrayList<String>();
doSomething(al);
List<String> ll = new LinkedList<String>();
doSomething(ll);
List<String> s = new Stack<String>();
doSomething(s);
List<String> v = new Vector<String>();
doSomething(v);
I've just written a method that works with 4 different classes (and probably many more), simply because instead of defining its parameter as a class, I defined it as an interface; and because I did that, it'll work with any class that implements List (or, in the above case, List).
And when you define a field (eg, 'al' above), if you define it using the interface type, you can change your mind later. Assuming that all my methods are written to take Lists, rather than ArrayLists, I can change the above definition to:
List al = new AttributeList();
and everything will continue to work just fine.