Quote:
|
Originally Posted by säkki
well it actually isn't descended from List<Person>, if I understand what you mean. cInd contains three kind of "persons" could be like this:
cInd {Person("FN", "LN"), Student("FN", "LN"), Worker("FN", "LN")} <- not meant to be anykind of syntax  just to clarify things.
Student and Worker are descended from Person.
|
Java 1.5 has a new feature called generics, which, amongst other things, allows you you to tie a type to a container
Before Java 1.5, you had to cast an element as the correct type when removing it from a container:
Vector list = new Vector();
list.add("Hello");
list.add("World");
String lastElement = (String)list.get(0); In Java 1.5, you can use generics to tell the JVM which type to expect from a container:
Vector<String> list = new Vector<String>();
list.add("Hello");
list.add("World");
String lastElement = list.get(0); The class Vector<Person> will take Persons, and descedants of Persons (ie. Workers and Students).
Vector<Person> persons = new Vector<Person>();
persons.add(new Person("A", "B"));
persons.add(new Worker("A", "B"));
persons.add(new Student("A", "B"));
for (Person person : persons) {
System.out.println(person);
} Of course, if you're not using Java 1.5, you can safely ignore all this talk about generics.
Quote:
|
Originally Posted by säkki
Thanks for these tips allready, I'll try to get forward in this but I really am miserable in this.
|
You seem to be doing okay so far
