Mercurial > hg > Papers > 2021 > anatofuz-master
annotate paper/src/java-interface-implements.java @ 131:988b3024d685
update
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Feb 2021 05:49:37 +0900 |
parents | 3a8c21a37bf1 |
children |
rev | line source |
---|---|
56 | 1 // interface |
2 interface Animal { | |
3 public void animalSound(); // interface method (does not have a body) | |
4 public void sleep(); // interface method (does not have a body) | |
5 } | |
6 | |
7 // Pig "implements" the Animal interface | |
8 class Pig implements Animal { | |
9 public void animalSound() { | |
10 // The body of animalSound() is provided here | |
11 System.out.println("The pig says: wee wee"); | |
12 } | |
13 public void sleep() { | |
14 // The body of sleep() is provided here | |
15 System.out.println("Zzz"); | |
16 } | |
17 } |