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


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

in Table To:


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