Basic HTML version of Foils prepared July 6 99

Foil 27 Example of basic language syntax

From Use of Java Language in Computational Science DoD Modernization Users Group Conference Monterey -- June 7 99. by Nancy McCracken, 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 Tue Jul 6 1999