This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
java:hiding_static_methods [2015/02/15 17:40] gthanos |
java:hiding_static_methods [2015/04/20 06:50] gthanos |
||
---|---|---|---|
Line 29: | Line 29: | ||
public static void main(String[] args) { | public static void main(String[] args) { | ||
Cat myCat = new Cat(); | Cat myCat = new Cat(); | ||
- | Animal myAnimal = myCat; | + | Animal myAnimalCat = myCat; |
- | Animal yourAnimal = new Animal(); | + | Animal myAnimal = new Animal(); |
| | ||
Animal.testClassMethod(); | Animal.testClassMethod(); | ||
Line 37: | Line 37: | ||
System.out.println(""); | System.out.println(""); | ||
+ | myAnimalCat.testClassMethod(); | ||
myAnimal.testClassMethod(); | myAnimal.testClassMethod(); | ||
- | yourAnimal.testClassMethod(); | ||
myCat.testClassMethod(); | myCat.testClassMethod(); | ||
System.out.println(""); | System.out.println(""); | ||
| | ||
- | myCat.testInstanceMethod(); | + | myAnimalCat.testInstanceMethod(); |
myAnimal.testInstanceMethod(); | myAnimal.testInstanceMethod(); | ||
- | yourAnimal.testInstanceMethod(); | + | myCat.testInstanceMethod(); |
} | } | ||
} | } | ||
Line 60: | Line 60: | ||
The static method in Cat | The static method in Cat | ||
- | The instance method in Cat | ||
The instance method in Cat | The instance method in Cat | ||
The instance method in Animal | The instance method in Animal | ||
+ | The instance method in Cat | ||
+ | |||
</code> | </code> | ||