mirror of
https://github.com/rizinorg/rizin-testbins.git
synced 2026-11-08 07:58:44 -10:00
28 lines
667 B
Java
28 lines
667 B
Java
package rizinjava;
|
|
|
|
// Interface
|
|
interface Animal {
|
|
public void animalSound(); // interface method (does not have a body)
|
|
public void sleep(); // interface method (does not have a body)
|
|
}
|
|
|
|
// Pig "implements" the Animal interface
|
|
class Pig implements Animal {
|
|
public void animalSound() {
|
|
// The body of animalSound() is provided here
|
|
System.out.println("The pig says: wee wee");
|
|
}
|
|
public void sleep() {
|
|
// The body of sleep() is provided here
|
|
System.out.println("Zzz");
|
|
}
|
|
}
|
|
|
|
class MainAnimals {
|
|
public static void main(String[] args) {
|
|
Pig myPig = new Pig(); // Create a Pig object
|
|
myPig.animalSound();
|
|
myPig.sleep();
|
|
}
|
|
}
|