Tuesday, March 29, 2011

Difference Between instanceOf and IsInstance

1) instanceof is a reserved word of Java, but isInstance(Object obj) is a method of java.lang.Class.
if (obj instanceof MyType) {
}else if (MyType.class.isInstance(obj)) {
2) instanceof is used of identify whether the object is type of a particular class or its subclass but isInstance(obj) is used to identify object of a particular class.

1 comment:

  1. This comment has been removed by the author.