instanceof Keyword in Java


The instanceof keyword checks whether an object is an instance of a specific class or interface.

Source Code

String name = "Java";
boolean result = name instanceof String; // true
System.out.println(result);

Use instanceof for type checking in your code, especially before casting objects to a specific class.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments