home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-04-19 | 367 b | 13 lines |
- class Fruit { }
- class Apple extends Fruit {
- public static void main(String[] args) {
- Apple a = new Apple();
- if (a instanceof Apple)
- System.out.println("A is for Apple");
- if (a instanceof Fruit)
- System.out.println("A is a Fruit");
- if (a instanceof Object)
- System.out.println("A is an Object");
- }
- }
-