The InstanceOf Keyword

Posted By on September 16, 2014


Download PDF
Static Keyword
Java Util Packages
The instanceof keyword can be used to test if an object is of a specified type.
if (objectReference instanceof type)
The following if statement returns true.
public class MainClass {
  public static void main(String[] a) {

    String s = "Hello";
    if (instanceof java.lang.String) {
      System.out.println("is a String");
    }
  }

}

Static Keyword
Java Util Packages

Download PDF

Posted by Akash Kurup

Founder and C.E.O, World4Engineers Educationist and Entrepreneur by passion. Orator and blogger by hobby

Website: http://world4engineers.com