Solved

Determining Object Type

Posted on 2003-11-15
2
236 Views
Last Modified: 2010-03-31
If I have an Object, but want to determine what subclass of Object it is, is there anyway to do that? In other words, how do I determine object type?
0
Comment
Question by:handle0001
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 75 total points
ID: 9756699
You can get the class using:

Class clazz = o.getClass();

You can test if it is instance of a class/interface using:

if (o instanceof Serializable)
0
 
LVL 92

Expert Comment

by:objects
ID: 9756932
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to convert from xls to xlsx using java 7 55
jsp insert to database example 2 44
Bot application - advice 3 37
Cisco ASA: Java web start no go, asdm launcher no go 3 34
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question