W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
class Main {
  public static void main(String[] args) {
    DemoClass myObj = new DemoClass();
    myObj.myMethod();
    myObj.myOtherMethod();
  }
}
​
interface FirstInterface {
  public void myMethod(); // 接口方法
}
​
interface SecondInterface {
  public void myOtherMethod(); // 接口方法
}
​
// DemoClass 实现了 FirstInterface 和 SecondInterface
class DemoClass implements FirstInterface, SecondInterface {
  public void myMethod() {
    System.out.println("一些文本..");
  }
  public void myOtherMethod() {
    System.out.println("另一些文本...");
  }
}
​