Section 3.3 Primitive Types vs. Reference Types
• Types in Java are divided into two categories—primitive types and reference types. The primitive types are boolean
, byte
, char
, short
, int
, long
, float
and double
. All other types are reference types, so classes, which specify the types of objects, are reference types.
• A primitive-type variable can store exactly one value of its declared type at a time.
• Primitive-type instance variables are initialized by default. Variables of types byt
e, char
, short
, int
, long
, float
and double
are initialized to 0
. Variables of type boolean
are initialized to false
.
• Reference-type variables (called references; p. 81) store the location of an object in the computer’s memory. Such variables refer to objects ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.