CMSC 132A Lecture Notes - Lecture 3: Type Signature, Type Safety, Xml

29 views6 pages

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:

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents