instanceof operator: Used only for object reference variables, check that the test object on the left is not an instantiation of the right class or interface. If the object being measured is a null value, the test result is always false.
Image: Self instance or subclass instance Instanceof itself class returns True
Example: String S=new string ("Javaisland");
System.out.println (S instanceof String);//true
the class Isinstance (Object obj) method, where obj is the object being tested and returns true if Obj is an instance of the class or interface that called the method. This method is the dynamic equivalent of the instanceof operator, and if obj is null, the test result is always false. Image: Own class. Class.isinstance (instance of itself or subclass) returns True
Example: String S=new string ("Javaisland");
System.out.println (String.class.isInstance (s));//true
Class IsAssignableFrom (Class CLS) method, which returns true if the class or interface calling this method is the same as the classes or interfaces represented by the parameter CLS, or is the parent class of the class or interface that the parameter CLS represents.
Image: Own class. Class.isassignablefrom (Own class or subclass. Class) returns True
Example: System.out.println (ArrayList.class.isAssignableFrom (Object.class)); False
System.out.println (Object.class.isAssignableFrom (Arraylist.class)); True
Instanceof, Isinstance,isassignablefrom differences