Instance Of Operator Example Java Program


A binary operator that takes an object reference as its first operand and a class or interface as its second operand and produces a boolean result. The instanceof operator evaluates to true if and only if the runtime type of the object is assignment compatible with the class or interface.

Instance Of Operator Example Program

public class InstanceOfOperator {
	public static void main(String args[]){
		String str = "Julie";
		System.out.println("The input string is: "+str);
		boolean result = str instanceof String;  
		System.out.println( result );

Sample Output

Output is:
The input string is: Julie