Basic HTML version of Foils prepared Feb 19 1999

Foil 11 Arrays and "For" Loops

From Computing and Java Language Basics NPAC Java Academy February--April 99 -- Feb 13 1999. by Nancy McCracken


To assign or use all the elements of an array in order, a "for" loop is handy.
int max = 8;
int numbers [ ] = new int [ max ] ;
for ( int i = 0; i < numbers.length; i++ )
{
numbers [ i ]= i * 2;
}
0 1 2 3 4 5 6 7
0 2 4 6 8 10 12 14



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Mon Jul 5 1999