Top "Instanceof" questions

instanceof is an operator available in some object-oriented languages, including Java, php and JavaScript.

Java .equals() instanceof subclass? Why not call superclass equals instead of making it final?

It is stated in Object's .equals(Object) javadoc: It is symmetric: for any non-null reference values x and y, x.…

java equals instanceof
java: combined instanceof and cast?

(Please no advise that I should abstract X more and add another method to it.) In C++, when I have …

java casting instanceof dynamic-cast
Instanceof and namespaces

I am facing an unexpected behaviour trying to use the following: $object instanceof $class 1/ PHP 'instanceof' keyword and namespaces work …

php instanceof
JavaScript inheritance and the constructor property

Consider the following code. function a() {} function b() {} function c() {} b.prototype = new a(); c.prototype = new b(); console.log((…

javascript inheritance constructor instanceof
Avoiding 'instanceof' in Java

I have the following (maybe common) problem and it absolutely puzzles me at the moment: There are a couple of …

java oop instanceof
Difference between RTTI and reflection in Java

My question is when how does the class info gets loaded during runtime? When someone calls instanceof is that considered …

java reflection terminology rtti instanceof
How to retrieve the activity requested by an Intent

Say I have an Intent like this: Intent intent = new Intent(context, MyActivity.class); I then want a method that …

android class android-intent instanceof
Java: How to check if an object is an instance of a non-static inner class, regardless of the outer object?

If I have an inner class e.g. class Outer{ class Inner{} } Is there any way to check if an …

java inner-classes instanceof
How does one use polymorphism instead of instanceof? (And why?)

If we take the code below: Shape p1 = new Square(); Square c1; if(p1 instanceof Square) { c1 = (Square) p1; } What …

java polymorphism instanceof
Is This Use of the "instanceof" Operator Considered Bad Design?

In one of my projects, I have two "data transfer objects" RecordType1 and RecordType2 that inherit from an abstract class …

java design-patterns instanceof object-oriented-analysis