Created
January 13, 2024 04:46
-
-
Save lol97/78ad3a987d6e3dcebf23d6fef3c2b53f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Animalia{ | |
| class Carnivora { | |
| public void showPrey() { | |
| System.out.println("carnivora eat the meat"); | |
| } | |
| } | |
| public void discoverTiger(){ | |
| Carnivora tiger = new Carnivora(){ | |
| public void showPrey(){ | |
| System.out.println("tiger hunt and eat the meat of deer"); | |
| } | |
| }; | |
| tiger.showPrey(); | |
| } | |
| public static void main(String[] args){ | |
| Animalia animal = new Animalia(); | |
| animal.discoverTiger(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment