Languages
[Edit]
EN

Java - instanceof keyword simple usage example

4 points
Created by:
Nikki-Mathews
517

In java with instanceof keyword we can check if our object is instance of specific class or interface.

Quick solution:

Example with ArrayList instead of List:

Example with Object instead of List

Practical examples

Edit

Practical example 1:

Edit

Output:

Practical example 2:

Edit

Output:

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join