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


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

in Table To:


© 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