TYPES, VALUES, AND VARIABLES
Objects
4.3.1
//
An array is implicitly created by an array constructor:
Point a[] = { new Point(0,0), new Point(1,1) };
// String
s are implicitly created by
+
 operators:
System.out.println("p: " + p);
System.out.println("a: { " + a[0] + ", "
+ a[1] + " }");
//
An array is explicitly created by an array creation expression:
String sa[] = new String[2];
sa[0] = "he"; sa[1] = "llo";
System.out.println(sa[0] + sa[1]);
}
}
which produces the output:
default
p: (0,0)
a: { (0,0), (1,1) }
hello
The operators on references to objects are:
Field access, using either a qualified name ( 6.6) or a field access expression
( 15.10)
Method invocation ( 15.11)
The cast operator ( 5.4,  15.15)
The string concatenation operator
+
 ( 15.17.1), which, when given a
String
operand and a reference, will convert the reference to a
String
 by invoking
the
toString
 method ( 20.1.2) of the referenced object (using
"null"
 if
either the reference or the result of
toString
 is a null reference), and then
will produce a newly created
String
 that is the concatenation of the two
strings
The
instanceof
 operator ( 15.19.2)
The reference equality operators
==
 and
!=
 ( 15.20.3)
The conditional operator
? :
 ( 15.24).
There may be many references to the same object. Most objects have state,
stored in the fields of objects that are instances of classes or in the variables that
are the components of an array object. If two variables contain references to the
same object, the state of the object can be modified using one variable's reference
to the object, and then the altered state can be observed through the reference in
the other variable.
39






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