集册 Java实例教程 与嵌套类和常量字段的接口

与嵌套类和常量字段的接口

欢马劈雪     最近更新时间:2020-01-02 10:19:05

464
与嵌套类和常量字段的接口

interface Walkable {

  // A nested class

  class Dog implements Walkable {

    private Dog() {
    /*
    来 自*
     NowJava.com
    */

      // Do not allow outside to create its object

    }


    public void walk() {

      System.out.println("Nothing serious to run...");

    }

  }
/*from 时代Java公众号*/

  Walkable Default = new Dog();

  

  // An abstract method

  void walk();

}



public class Main {

  public static void main(String[] args) {

    my(
展开阅读全文