Overview
Overview
While refactoring old code, you might have already encountered that the classes are inundated with lots of non-generic List. It is important for a codebase to evolve and that’s why I would like to discuss about how to refactor your old non-generic List to generic List.
Example
Here, you can clearly see to cast a generic
to
, we have to take 2 steps. Initially, we have to safely cast it to unbounded wildcard List and then to the actual
. The same method applies for non-generic List or raw type List as it is as same as
.
You would also get to see Unchecked Cast warning which informs you about the presence of cast from a generic type to a non-qualified type or the vice versa.