Nicely said. I would also add a paragraph about erasure. Essentially, that first code without generics would still compile today and produce some warnings, but work as expected.
Technically, generic code compiles to something pretty similar. The generic data is erased so code like this is legal:
privatevoidmyMethod(List<MyObject> data){
List myList = (List)data;
//...
}
Yak Barber, duck whisperer, hunter of bugs, feeder of dogs, heap climber, stack explorer and rider of shells
Shai Almog
Nicely said. I would also add a paragraph about erasure. Essentially, that first code without generics would still compile today and produce some warnings, but work as expected.
Technically, generic code compiles to something pretty similar. The generic data is erased so code like this is legal:
private void myMethod(List<MyObject> data) { List myList = (List)data; //... }