CMSC 132A Lecture Notes - Lecture 3: Type Signature, Type Safety, Xml
Document Summary
A raw type is the name of a generic class or interface without any type arguments. For example, given the generic box class: public class box { public void set(t t) { /* */ } To create a parameterized type of box, you supply an actual type argument for the formal type parameter t: If the actual type argument is omitted, you create a raw type of box: Therefore, box is the raw type of the generic type box. However, a non-generic class or interface type is not a raw type. Raw types show up in legacy code because lots of api classes (such as the collections classes) were not generic prior to jdk 5. 0. When using raw types, you essentially get pre-generics behavior a box gives you objects. For backward compatibility, assigning a parameterized type to its raw type is allowed: But if you assign a raw type to a parameterized type, you get a warning: