TYPES, VALUES, AND VARIABLES
Variables Have Types, Objects Have Classes
4.5.5
The local variable
c
 has as its type the interface type
Colorable
, so it can
hold a reference to any object whose class implements
Colorable
; specifi 
cally, it can hold a reference to a
ColoredPoint
.
Note that an expression such as  
new Colorable()
  is not valid because it is
not possible to create an instance of an interface, only of a class.
Every array also has a class; the method
getClass
 ( 20.1.1), when invoked
for an array object, will return a class object (of class
Class
) that represents the
class of the array. The classes for arrays have strange names that are not valid Java
identifiers; for example, the class for an array of
int
 components has the name
[I
  and so the value of the expression:
new int[10].getClass().getName()
is the string
"[I"
; see  20.1.1 for details.
Oft on the dappled turf at ease
I sit, and play with similes,
Loose types of things through all degrees.
 William Wordsworth,
To the Same Flower
49






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