Prefer using parameterized types over raw types

posted 29 Dec 2010, 04:58 by Sanjeev Kumar   [ updated 11 Nov 2011, 06:14 ]

When generics were introduced in JDK 1.5, raw types were retained only to maintain backwards compatibility with older versions of Java. Although using raw types is still possible, they should be avoided for following reasons :
  • they usually require casts
  • they aren't type safe, and some important kinds of errors will only appear at runtime
  • they are less expressive, and don't self-document in the same way as parameterized types
Unless you are using a JDK version prior to 1.5 I don't see a reason why you should not use parameterized types in your code.

Happy coding !!
Comments