Back to Using Objects

Lesson PreviewLesson 9 of 10 in this unit

2.8 Wrapper Classes: Integer and Double

Part of Using Objects in AP® Computer Science A. Read the opening section, then create a free account for the full interactive lesson, practice, and progress tracking.

Wrapper Classes: Integer and Double

In Java, a wrapper class is a class that allows you to convert a primitive data type into an object. For example, the primitive int has a corresponding wrapper class called Integer, and the primitive double has a wrapper class called Double.

Wrapper classes let you treat primitive values like objects. They also have methods for converting between types and accessing metadata, which is useful information describing its properties, such as Integer.MAX_VALUE, which we have learned about in 1.2. Most importantly. they are useful for working with Java collections like ArrayList, which only work with objects. We will learn more about ArrayList in unit 7.

Continue the full lesson in Stellar

Create a free account to unlock the remaining sections, checkpoints, course practice, and progress tracking for AP® Computer Science A.