Back
If class B and class C extend class A and I have an object of type B or C, how can I determine of which type it is an instance?
Simply, use this syntax to determine an object's class:
if (obj instanceof C) {//your code}
if (obj instanceof C) {
//your code
}
Click here to learn more about Object.getClass()
31k questions
32.8k answers
501 comments
693 users