java:instanceof
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| java:instanceof [2017/02/14 09:18] – gthanos | java:instanceof [2020/02/25 09:33] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| 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)); |
| - | } | + | } |
| } | } | ||
| </ | </ | ||
| Line 50: | Line 50: | ||
| obj2 instanceof MyInterface: | obj2 instanceof MyInterface: | ||
| </ | </ | ||
| + | |||
| + | |Προηγούμενο: | ||
java/instanceof.1487063901.txt.gz · Last modified: 2017/02/14 09:18 (external edit)
