how to check type of object in java code example
Example 1: how to check object type in java
String str = "a String made by the String class";
if(str instanceof String) System.out.println("This is True");
if(str instanceof float) System.out.println("This will never be on your screen");
Example 2: how to find the class of an object java
String str = "a String made by the String class";
if(str instanceof String) System.out.println("This is True");
if(str instanceof float) System.out.println("This will never be on your screen");