comparing object with class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

comparing object with class

how to comparing object with class? without create instance of class. for exemple: class A {} class B extends A {} main() { B b = new B(); A a = (A) b; //how to check that a is an instance of B class }

9th Jan 2019, 7:29 AM
Azeddine Hamdaoui
Azeddine Hamdaoui - avatar
3 Answers
+ 5
Java has instanceof operator that is supposed to do what you want. See here https://www.geeksforgeeks.org/java-instanceof-and-its-applications/
9th Jan 2019, 7:54 AM
KrOW
KrOW - avatar
+ 2
👍👍👍
9th Jan 2019, 8:03 AM
KrOW
KrOW - avatar
+ 1
yeah thats right thanks a lot :)
9th Jan 2019, 7:59 AM
Azeddine Hamdaoui
Azeddine Hamdaoui - avatar