package com.Summer_0427.cn;


interface Info{
    int N = 11;//public static final int N = 11;
    //抽象
    //默认
    default void df() {
        System.out.println("df");
    }
    //不能被 子接口 和 实现类继承的
    public static void sf() {
        System.out.println("sf");
    }
}
class InfoImpl implements Info{
    public void show() {
        System.out.println(N);//继承了父接口中的常量
//        N = 56;//常量不可以修改
        df();//可以被继承过来
        Info.sf();//静态方法的调用,想不创建一个对象直接调用接口的方法,定义成一个静态方法
    }
}
public class TestInfo {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

}

 

相关文章:

  • 2021-10-30
  • 2022-02-09
  • 2022-01-09
  • 2022-02-09
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2021-12-19
  • 2022-12-23
  • 2021-05-28
相关资源
相似解决方案