O'Reilly logo

Programming with Java by Sunil Patekar, Mahesh Bhave

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 9

WRAPPER CLASSES

When we give gifts, we wrap them nicely in a box. The gift may be a doll or a toy car or something else. The box and the glossy paper around it make it attractive. We have worked with simple data types. Now Java wants to wrap them and make them more attractive (useful). For this, Java provides an interesting concept of wrapper classes.

9.1 Introduction

We have studied the basic data type float. It holds floating-point number. Now Java provides a class Float. As identifiers are case sensitive, Float and float are different. The new class Float is for storing floating-point values only. But it is a class, a wrapper class.

Similarly, a bare number of type int is wrapped nicely in a class Integer. We know that classes have ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required