ARRAYS
Array Members
10.7
An array initializer is written as a comma separated list of expressions,
enclosed by braces  
{
  and  
}
 .
The length of the constructed array will equal the number of expressions.
Each expression specifies a value for one array component. Each expression
must be assignment compatible ( 5.2) with the array's component type, or a com 
pile time error results.
If the component type is itself an array type, then the expression specifying a
component may itself be an array initializer; that is, array initializers may be
nested.
A trailing comma may appear after the last expression in an array initializer
and is ignored.
As an example:
class Test {
public static void main(String[] args) {
int ia[][] = { {1, 2}, null };
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
System.out.println(ia[i][j]);
}
}
prints:
1
2
before causing a
NullPointerException
 in trying to index the second compo 
nent of the array
ia
, which is a null reference.
10.7   Array Members
The members of an array type are all of the following:
The
public final
 field
length
, which contains the number of components
of the array (
length
 may be positive or zero)
The
public
 method
clone
, which overrides the method of the same name in
class
Object
 and throws no checked exceptions
All the members inherited from class
Object
; the only method of
Object
 that
is not inherited is its
clone
 method
An array thus has the same methods as the following class:
197






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