Mercurial > hg > Papers > 2021 > anatofuz-master
comparison paper/src/java-interface-implements.java @ 56:3a8c21a37bf1
interface
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 02 Feb 2021 14:17:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
55:76eee6847726 | 56:3a8c21a37bf1 |
---|---|
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 } |