Basic HTML version of Foils prepared October 30 1999

Foil 10 Arrays and For Loops

From Short Introduction to Kids on Basic Programming Concepts in Java Sonia Kovalesky festival workshop (High School Girls) -- October 23 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 Sat Oct 30 1999