Just thought running a grep on those daily musings - on mobile world mainly - might be amusing!
Friday, February 25, 2005
Non generic collections in J2SE 5.0
It seems you cannot use the plain old collection objects - the non generic versions aka "raw" collections - anymore without getting unchecked warnings!
The following code doesn't use any generics but compiler throws unchecked warnings as shown below:
List c = new ArrayList();
c.add(new Object());
>javac -Xlint Test.javaTest.java:10: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
c.add(new Object());
^
1 warning
Compiler has infact recognized the "raw" type but still decides to throw a generic related - note the type variable E - warning. Price for "guaranteed" type safety I guess!
Food for thought: IT folks are usually skeptical about the X.0 versions and tend to wait for the X.xx before taking the plunge!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment