接口是一种特殊的类,它由全局变量和公共的抽象方法所组成。
接口的抽象方法必须定义为public的访问权限,如果方法定义省略了public,默认的权限是public,而不是default;
例:接口的定义
interface A { public static final String username="jack"; public abstract void print(); public abstract String getInfo(); }
也可以简化成如下格式:
interface A{ String username="jack"; void print(); String getInfo(); }