Basic HTML version of Foils prepared June 5 99

Foil 43 Example of basic language syntax

From Java Language in the Computer Science Curriculum ADMI Tutorial Duluth Minnesota -- June 3 99. by Geoffrey C. Fox


public class SumArray
{
public static void main (String[] args)
{ // array declaration
int a[ ] = new int[10];
int total=0;
/* initialize a - note the use of array instance variable length */
for (int i = 0; i < a.length; i++)
{ a[i] = i * 5; }
/* sum the array */
for (int i = 0; i < a.length; i++)
total += a[i];
System.out.println( "\n" + "The sum of the array is " + total + "\n");
}
}
Familiar C operators ++ and +=
String catenation



© 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 Jun 5 1999