About 1,580,000 results
Open links in new tab
  1. operators - Use of "instanceof" in Java - Stack Overflow

    What is the 'instanceof' operator used for? I learned that Java has the instanceof operator. Can you elaborate where it is used and what are its advantages?

  2. What is the 'instanceof' operator used for in Java?

    The java instanceof operator is used to test whether the object is an instance of the specified type (class or subclass or interface). The instanceof in java is also known as type comparison …

  3. java - How to determine an object's class? - Stack Overflow

    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?

  4. Java: Instanceof and Generics - Stack Overflow

    Oct 15, 2009 · Java: Instanceof and Generics Asked 16 years, 1 month ago Modified 3 years, 1 month ago Viewed 249k times

  5. java - How instanceof will work on an interface - Stack Overflow

    Nov 21, 2012 · 70 instanceof can be used to test if an object is a direct or descended instance of a given class. instanceof can also be used with interfaces even though interfaces can't be …

  6. java - Is null check needed before calling instanceof? - Stack …

    Jun 1, 2010 · The instanceof operator does not need explicit null checks, as it does not throw a NullPointerException if the operand is null. At run time, the result of the instanceof operator is …

  7. The performance impact of using instanceof in Java

    Sep 19, 2008 · 363 I am working on an application and one design approach involves extremely heavy use of the instanceof operator. While I know that OO design generally tries to avoid …

  8. java - What is the difference between instanceof and Class ...

    The syntax is a instanceof Bref not a instanceof Bref.class. The second argument to the instanceof operator is a class name, not an expression resolving to a class object instance.

  9. java - Best way to "negate" an instanceof - Stack Overflow

    This has different behaviour. The instanceof keyword includes subclasses, the method does not, you need to use Class.isAssignableFrom to replicate the behaviour.

  10. Test if object is instanceof a parameter type - Stack Overflow

    Then you can get the class of that object, see java.lang.Class<T> and find if it's the same as the object in question. But note that this goes counter the very reason we have genrics: using a …