java.lang.Class.isInstance()


java.lang.Class.isInstance()

package com.codingdict;



import java.lang.*;



public class ClassDemo {



   public static void main(String[] args) {



      // Long object represented by class object

      Class cls = Long.class;



      Long l = new Long(86576);

      Double d = new Double(3.5);



      // checking for Long instance

      boolean retval = cls.isInstance(l);

      System.out.println(l + " is Long ? " + retval);



      // checking for Long instance

      retval = cls.isInstance(d);

      System.out.println(d + " is Long ? " + retval);        

   }

}