Skip to content

Instantly share code, notes, and snippets.

@lol97
Created January 13, 2024 04:46
Show Gist options
  • Select an option

  • Save lol97/78ad3a987d6e3dcebf23d6fef3c2b53f to your computer and use it in GitHub Desktop.

Select an option

Save lol97/78ad3a987d6e3dcebf23d6fef3c2b53f to your computer and use it in GitHub Desktop.
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