Basic HTML version of Foils prepared 18 May 97

Foil 14 Determining and Testing Class of Object

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


1 Suppose an object is called obj , then we get Class of obj by
2 Class itsclass = obj.getClass(); // and the name of this class by:
3 String name = itsclass.getName();
4 One can also use instanceof in following fashion
5 "foo" instanceof String // is evaluated to true but
6 mPoint pt = new mPoint(x,y);
7 pt instanceof String // is evaluated 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 Thu Jan 8 1998