Basic HTML version of Foils prepared 18 May 97

Foil 22 Methods for Vectors

From Java Tutorial - Spring 1997 Part 4: Multithreading, useful Java classes, I/O, Networking, and the future Peking Tutorial, Web Certificate -- Spring-Summer 1997. by Nancy J. McCracken,Geoffrey C. Fox


Elements are created with the addElement method:
  • Order missouri = new Order();
  • orders.addElement(missouri);
The object missouri of type Order is automatically converted to an Object in vector instance orders defined on previous foil.
There are methods for indexing vectors. Like arrays, the indexing is zero-based.
  • x = (Typeofx) v.elementAt(i);
  • v.setElementAt(x,i);
The length of the Vector can be obtained:
  • int size = v.size;



© 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 Thu Jan 8 1998