HELP! * GREY=local LOCAL HTML version of Foils prepared 29 January 1996

Foil 32 Java Language -- Types: Array

From CPS616 Lectures on Java CPS616 Basic Information Track for Computational Science -- Winter-Spring Semester 96. by Geoffrey C. Fox * See also color IMAGE

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