• java


    interface

    不能有一般属性,只能有共有静态常量(public static final String = name) (必须赋值)  不写的话也能过编译,但是会默认设定为public static final,子类中不能修改值

    不能有一般方法,只能有共有静态方法,或者default(JDK1.8)

    不能含有一般程序块和静态方法。

    不能含有构造方法。

    可以直接继承接口,使用implements

     类使用implements继承接口,可以继承多个,用逗号隔开。

    普通类必须实现接口中的方法,抽象类和接口可以不实现

    package interfaceTest;
    
    public interface InterfaceTest {
        public static final String name = "aaa";
        public static int age = 10;
        public int aaa = 20;
    
        public void show();
    }
    package interfaceTest;
    
    public interface InterfaceTest2 {
    }
    package interfaceTest;
    
    public class InterfaceTestChild implements InterfaceTest, InterfaceTest2 {
    
        public void show(){
            System.out.println("name = " + name + " age = " + age + " aaa = " + aaa );
        }
    
        public static void main(String[] args) {
            InterfaceTestChild inter = new InterfaceTestChild();
            inter.show();
        }
    }
  • 相关阅读:
    group by;having;order by
    oracle官方文档
    oracle正则表达式函数和正则表达式简介
    oracle系统函数
    oracle系统表
    windows搭建ftp服务器
    开机自动挂载
    linux修改设置ip地址
    My First Web Server
    为什么要写博客?
  • 原文地址:https://www.cnblogs.com/clamp7724/p/11604779.html
Copyright © 2020-2023  润新知