Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

Java instance of an operator

  • • The instance is an object reference operator and returns a Boolean value that is true or false if the object on the left-hand side is an instance of the class given on the right-hand side.
  • • This operator allows us to determine whether the object belongs to a particular class or not.

Example:

name instanceof String Is true if the object person belongs to the class employee, otherwise it is false.

class InstanceDemo
{
	public static void main(String args[])
	{
		String name="Tapuuu";
		boolean x=name instanceof String;
		System.out.println(x);
	}
}

Output :

true

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext