Basic HTML version of Foils prepared May 12 1996

Foil 42 Java Language -- Types: Array

From CRPC Lectures on Java Language Applets Graphics CRPC Annual Meeting Tutorial -- May 14,1996. by Geoffrey C. Fox


An Array is declared as:
  • int vec[];
and created by:
  • vec = new int[128];
or concisely:
  • int vec[] = new int[128];
Subscripts are range checked in runtime and so vec[-1] and vec[128] will generate exceptions.
Array length can be extracted via the length instance variable, e.g.
  • int len = vec.length will assign len = 128.
Arrays of arbitrary objects can be constructed,
  • e.g. Thread myThreadList[] = new Thread[1024];
Arrays can have dynamic sizing
  • int sizeofarray = 67;
  • int vec[] = new int[sizeofarray];



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 Sun Dec 14 1997