您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes
Introduction
Content
Apply
Reflect
Extend
previous.gif
 (3087 bytes)
next.gif
 (2959 bytes)

 
 
Content Index
Content Page # 7

Defining the dimensions of an array

The general form of defining an array dimension is:

<array_identifier> = <type>[<dimension>]; Examples of arrays having their dimension defined include: intials = new char[3];
appointments = new Date[365];
No values are placed into the array when it is defined, however, an array element is created to store each variable of the defined type. So, for example, the array initials after definition of size 3 can be illustrated as follows:
 
char initials []
element
value
initials [0]
''
initials [1]
''
initials [2]
''
We can place values into these array elements with variable assignment statements. So for example, to place the characters 'I', 'N' and 'T' into this array we could use the following statements:
initials[0] = 'I';
initials[1] = 'N';
initials[2] = 'T';
Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg