+ 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 odpowiedzi
+ 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