Hello I need to know if there is a way to find out what an object extends in Java.
public void function(Obj obj)
{
// ...
Is there a way to find out what obj extends? or if it extends anything?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume you mean that you want to find out which class this object is an instance of. In this case you can simply use
Object.getClass(). Also you haveClass.getSuperclass()at your disposal if you need to find the superclasses of the object class.