Basic HTML version of Foils prepared May 12 1996

Foil 74 Determining and Testing Class of Object

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


Suppose an object is called obj , then we get Class of obj by
Class itsclass = obj.getClass(); // and the name of this class by:
String name = itsclass.getName();
One can also use instanceof in following fashion
"foo" instanceof String // is evaluated to true but
mPoint pt = new mPoint(x,y);
pt instanceof String // is evaluated to false



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