For a number of reasons that (believe it or not) are not as vast as you think, we are still (sigh) using Java 1.4 to build and run our code (although we plan to finally switch to Java 7 at the end of the year) .
Our existing code that uses Collection classes doesnβt really clarify what is expected in Collection . Obviously, you can read the code and see what the downcasts will end and draw a conclusion from this, but you cannot just look at the declaration of the method and find out that the Collection object, which is the argument of the method or the return value of the method, actually takes place.
In the new code that I write, and when I am in the older code that uses Collection s, I added comments in the line to Collections declarations to show what would be announced if generics were used. For instance:
Map theMap = new HashMap();
or
List someMethod(List jobs);
In keeping with the gloomy subjectivity here at SO, instead of asking what you think about it (although admittedly, I would like to know - I find this a little ugly, but still like to have type information) I ' d instead, just ask what, if anything, you will do to understand what is held by the pre-type Collection objects.
source share