ARRAYS
Array Store Exception
10.10
10.8
Class
 Objects for Arrays
Every array has an associated
Class
 object, shared with all other arrays with the
same component type. The superclass of an array type is considered to be
Object
,
as shown by the following example code:
class Test {
public static void main(String[] args) {
int[] ia = new int[3];
System.out.println(ia.getClass());
System.out.println(ia.getClass().getSuperclass());
}
}
which prints:
class [I
class java.lang.Object
where the string  
[I
  is the run time type signature for the class object  array
with component type
int
  ( 20.1.1).
10.9   An Array of Characters is Not a
String
In Java, unlike C, an array of
char
 is not a
String
 ( 20.12), and neither a
String
nor an array of
char
 is terminated by
 \u0000 
 (the
NUL
 character).
A Java
String
 object is immutable, that is, its contents never change, while
an array of
char
 has mutable elements. The method
toCharArray
 in class
String
 returns an array of characters containing the same character sequence as a
String
. The class
StringBuffer
 implements useful methods on mutable arrays
of characters ( 20.13).
10.10   Array Store Exception
If an array variable
v
 has type
A[]
, where
A
 is a reference type, then
v
 can hold a
reference to an instance of any array type
B[]
, provided
B
 can be assigned to
A
.
Thus, the example:
class Point { int x, y; }
class ColoredPoint extends Point { int color; }
199






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