Java Reference
In-Depth Information
java -cp logging.jar;. PackageInfo logging 1.0 logging.File
This time, you should see the following output:
Name: logging
Implementation title: Logging Implementation
Implementation vendor: Jeff Friesen
Implementation version: 1.0a
Specification title: Logging Specification
Specification vendor: Jeff Friesen
Specification version: 1.0
Sealed: true
Compatible with 1.0: true
Primitive Type Wrapper Class
The
java.lang
packageincludes
Boolean
,
Byte
,
Character
,
Double
,
Float
,
Integer
,
Long
, and
Short
. These classes are known as
primitive type wrapper
classes
because their instances wrap themselves around values of primitive types.
Note
The primitive type wrapper classes are also known as
value classes
.
Java provides these eight primitive type wrapper classes for two reasons:
• The Collections Framework (discussed in
Chapter 5
) provides lists, sets, and
mapsthatcanonlystoreobjects;theycannotstoreprimitivevalues.Youstorea
primitivevalueinaprimitivetypewrapperclassinstanceandstoretheinstance
in the collection.
• These classes provide a good place to associate useful constants (such as
MAX_VALUE
and
MIN_VALUE
) and class methods (such as
Integer
's
parseInt()
methodsand
Character
's
isDigit()
,
isLetter()
,and
toUpperCase()
methods) with the primitive types.
This section introduces you to each of these primitive type wrapper classes and a
java.lang
class named
Number
.
Boolean
Boolean
isthesmallestoftheprimitivetypewrapperclasses.Thisclassdeclaresthree
constants, including
TRUE
and
FALSE
, which denote precreated
Boolean
objects. It
also declares a pair of constructors for initializing a
Boolean
object: