4
C H A P T E R
Types, Values, and Variables
I send no agent or medium,
offer no representative of value,
but offer the value itself.
 Walt Whitman,
Carol of Occupations
 (1855),
in
Leaves of Grass
J
AVA is a
strongly typed
 language, which means that every variable and every
expression has a type that is known at compile time. Types limit the values that a
variable ( 4.5) can hold or that an expression can produce, limit the operations
supported on those values, and determine the meaning of the operations. Strong
typing helps detect errors at compile time.
The types of the Java language are divided into two categories: primitive types
and reference types. The primitive types ( 4.2) are the
boolean
 type and the
numeric types. The numeric types are the integral types
byte
,
short
,
int
,
long
,
and
char
, and the floating point types
float
 and
double
. The reference types
( 4.3) are class types, interface types, and array types. There is also a special null
type. An object ( 4.3.1) in Java is a dynamically created instance of a class type or
a dynamically created array. The values of a reference type are references to
objects. All objects, including arrays, support the methods of class
Object
( 4.3.2). String literals are represented by
String
 objects ( 4.3.3).
Types are the same ( 4.3.4) if they have the same fully qualified names and
are loaded by the same class loader. Names of types are used ( 4.4) in declara 
tions, in casts, in class instance creation expressions, in array creation expressions,
and in
instanceof
 operator expressions.
A variable ( 4.5) is a storage location. A variable of a primitive type always
holds a value of that exact type. A variable of a class type
T
 can hold a null refer 
ence or a reference to an instance of class
T
 or of any class that is a subclass of
T
.
A variable of an interface type can hold a null reference or a reference to any
instance of any class that implements the interface. If
T
 is a primitive type, then a
variable of type  array of
T
  can hold a null reference or a reference to any array
29






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved