posted 12 years ago
Dear Rohit,
Combination of legacy and generics is allowed so that the older codes don't break. In the main method, you have declared a collection
which is type safe, it means it can only take Integer. That's why when you try to add an integer into a type safe list, it raises an except.
As soon as you will pass it to the legacy method, it will generate a WARNING, but as soon as the control enters the legacy method, it is a
legacy list, which doesn't have any concept of type saftey. As legacy lists, used to support heterogeneous collections, this one will also and will
let a String added to the list. So no exception in the legacy method.
HTH,