Check out example codes for "java instanceof". It will help you in understanding the concepts better.

Code Example 1

The instanceof operator tests to see if the prototype property of a constructor 
appears anywhere in the prototype chain of an object. The return value is a 
boolean value.
For example :-

function Car(make, model, year) {
  this.make = make;
  this.model = model;
  this.year = year;
}
const auto = new Car('Honda', 'Accord', 1998);

console.log(auto instanceof Car);
// expected output: true

console.log(auto instanceof Object);
// expected output: true

Code Example 2

(object) instanceof (type)

Code Example 3

public class MyClass {
  public static void main(String[] args) {
    String myStr = "Hello planet earth, you are a great planet.";
    System.out.println(myStr.lastIndexOf("planet"));
  }
}

Learn ReactJs, React Native from akashmittal.com