HELP! * GREY=local LOCAL HTML version of Foils prepared July 10 1996

Foil 50 Java Language -- Types: Array

From Basic Lectures on Java Language Applets Graphics Networking Trip to China and Icase Tutorial -- July 12-28 and June 10-13 96. by Geoffrey C. Fox * See also color IMAGE

Arrays are "true" or "first class" objects in Java and no pointer arithmetic is supported.
An Array is declared as:
  • int vec[];
  • alternative syntax: int[] vec;
and created by:
  • vec = new int[128];
or concisely:
  • int vec[] = new int[128];
Arrays of arbitrary objects can be constructed,
  • e.g. Thread myThreadList[] = new Thread[1024];
  • The only difference is that in the case of primitive types, the array elements are actually allocated. In the case of arbitrary objects, an array of object references is created; before you use array elements, you must call the constructor of that type for each element.



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 Feb 18 1997