W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
class Main { public static void main(String[] args) { Pig myPig = new Pig(); myPig.animalSound(); myPig.sleep(); } } interface Animal { public void animalSound(); // 接口方法(没有方法体) public void sleep(); // 接口方法(没有方法体) } class Pig implements Animal { public void animalSound() { System.out.println("猪说:wee wee"); } public void sleep() { System.out.println("Zzz"); } }