12InterfacesWrappersSmall

12InterfacesWrappersSmall - Lecture Set#12 Polymorphism...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMSC 131 Fal 2009 Jan Plane (Adapted from Bonnie Dorr) Lecture Set #12: Polymorphism Introduction 1. Wrappers 2. Interfaces CMSC 131 Fal 2009 Jan Plane (Adapted from Bonnie Dorr) 1 Wrappers c We may want to treat primitives as though they were objects c For example, generic routines can be implemented using interfaces … but they are not usable on primitive types c To overcome this problem, Java provides wrappers for primitive types c Wrappers: classes whose objects contain single values of the “wrapped type” c Wrappers also contain other useful conversion operations (to / from String, etc.) c Wrappers included in java.lang : c Byte c Short c Integer c Long c Float c Double c Character c Boolean CMSC 131 Fal 2009 Jan Plane (Adapted from Bonnie Dorr) 2 The Integer Wrapper c The documentation is on-line at http://java.sun.com/j2se/1.5.0/docs/api/ c Notes c Immutable c Constructors c Implements Comparable c Documentation says “Comparable<Integer>” c Comparable in Java 5.0 is a interface c Has compareTo method.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 3

12InterfacesWrappersSmall - Lecture Set#12 Polymorphism...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online