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


1 Suppose we have an object called obj. We get the class of obj by:
  • Class class = obj.getClass();
2 and its name by:
  • String name = class.getName();
3 One can also use instanceof in following fashion:
  • "foo" instanceof String
4 evaluates to true, but
  • ( new mPoint(x,y) ) instanceof String
5 evaluates to false.

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 Sat Nov 28 1998