This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | Next revision Both sides next revision | ||
|
java:instanceof [2017/02/14 09:38] gthanos |
java:instanceof [2017/03/10 08:23] gthanos |
||
|---|---|---|---|
| Line 20: | Line 20: | ||
| <code java InstanceofDemo.java> | <code java InstanceofDemo.java> | ||
| class InstanceofDemo { | class InstanceofDemo { | ||
| - | | + | |
| - | | + | |
| - | Parent obj2 = new Child(); | + | Parent obj2 = new Child(); |
| - | | + | |
| - | + (obj1 instanceof Parent)); | + | + (obj1 instanceof Parent)); |
| - | System.out.println(" | + | System.out.println(" |
| - | + (obj1 instanceof Child)); | + | + (obj1 instanceof Child)); |
| - | System.out.println(" | + | System.out.println(" |
| - | + (obj1 instanceof MyInterface)); | + | + (obj1 instanceof MyInterface)); |
| - | System.out.println(" | + | System.out.println(" |
| - | + (obj2 instanceof Parent)); | + | + (obj2 instanceof Parent)); |
| - | System.out.println(" | + | System.out.println(" |
| - | + (obj2 instanceof Child)); | + | + (obj2 instanceof Child)); |
| - | System.out.println(" | + | System.out.println(" |
| - | + (obj2 instanceof MyInterface)); | + | + (obj2 instanceof MyInterface)); |
| - | } | + | } |
| } | } | ||
| </ | </ | ||