Tell me if I am wrong. in java language specifications 3rd edition, it was told that "All parametrized types shares the same class at runtime".
I think this differ from templates in C++ because templates make it as if their is more than one class in memory, each with a different type.
now I am scraching my head wondering that if parametrized types is trying to reduce ClassCastException in runtime and convert those runtime exceptions to compile time errors, so the code is more safer, and that is all parametrized types do.
calling parametrized type GENERIC is not accurate because actually any polymorphic behavior is generic. you can make LinkedList generic by making node of type Object,but what if you want to add some interface to the list, then you have to create a parametrized type LinkedList <T extends Object & SomeInterface>,
in other words, I cannot say that Vector<T> (where T extends Object by default) is any thing except more than "safty generic code" and actually, you can do it without <T>, by making Vector takes Object reference.
another question: Is parametrized types is something provided only since jdk 5.0.
To the 2nd question: Yes, this exists only since version 1.5
I don't know exactly how the internal system works, but in older version a Vector or a LikedList or whatever xould only store instances of Object. So if you wanted to access one of the elements you always had to cast it to it's type first. You could also cast it to another class type, but at runtime this woudl result in a ClassCastException.
Since Java 1.5 you can specify the class of the stored elements. This has 3 effects: 1. You can add only objects of the specified or an extending class. 2. If you access a element it is automatically casted to the right class 3. Class Cast Exceptions at runtime are not possible anymore if you don't force them (casting to Object, then casting to a wrong class for example).
The generic classes make programming easier and more secure. I really love this feauture, it really improves the readability of the code and you must really WANT to create a ClassCastException.
//old:
Vector myVector = new Vector();
myVector.add(anyObject);
.
.
((TargetClass)myVector.get(1)).targetClassMethod();
//new:
Vector myVector<TargetClass> = new Vector<TargetClass>();
myVector.add(targetClassInstance);
.
.
myVector.get(1).targetClassMethod();