When to use Class.isInstance() & when to use instanceof operator? [duplicate]

For instanceof you need to know the exact class at compile time.

if (foo instanceof ThisClassIKnowRightNow)
   ...

For isInstance the class is decided at run time. (late binding) e.g.

if (someObject.getClass().isInstance(foo))
   ...

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)