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
RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex
University. All rights reserved.
webmaster@globalcampus.com.eg
|