Basic HTML version of Foils prepared
Sept 21 1998
Foil 17 Determining and Testing Class of Object
From
Java Tutorial 98- 4: Multi-Treading, Useful Java Classes, I/O and Networking NAVO Tutorial --
Sept 23 1998
.
by
Geoffrey C. Fox, Nancy McCracken
Suppose we have an object called obj. We get the class of obj by:
Class class = obj.getClass();
and its name by:
String name = class.getName();
One can also use instanceof in following fashion:
"foo" instanceof String
evaluates to true, but
( new mPoint(x,y) ) instanceof String
evaluates 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 Sat Nov 28 1998