Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 2
    Instead of equals, you might want to use isInstance so it'll also accept child types. Commented Apr 6, 2014 at 12:50
  • @IdanArye Do you mean instanceof? Commented Apr 6, 2014 at 13:31
  • Class.isInstance(Object) (its in the comment in posted code fragment) Commented Apr 6, 2014 at 13:35
  • @Azar Not exactly. instanceof is a keyword and in order to use it you to write the name of the class inside the code. isInstance is a method of Class that you can use when you have the class as class object, and does the same thing as instanceof. Commented Apr 6, 2014 at 13:36
  • @MaciejChałapuk Sorry, didn't notice it. Still - isInstance as been around since Java 1.1 so I doubt it's not available on any Java platform that's still being used. Asker's platform is old, but it can't be that old... Commented Apr 6, 2014 at 13:38