Yes. Not only the order is wrong, but the object instanceof Clazz must have a class that is known at compile time. clazz.isInstance(object) can take a class that is known at runtime.
There is also a subtle difference in that isInstance will load automatically, but instanceof will not.
eg.
10 instanceof Integer // does not compile Integer.class.isInstance(10) // returns true Integer i = 10; if (i instanceof String) // does NOT compile if (String.class.isInstance(i)) // is false
To see the difference, I suggest you try using them.
Note: if you execute object.getClass().getClass() or myClass.getClass() , you just get Class Be careful not to call getClass() when you don't need it.
source share