例子:
定义:
interface MyService{
String name = "你真坏";
int getId();
}
-----------------
说明:
1.MyService接口:默认是abstract;默认也是default 或者叫 friendly,即 在同一个包或者类中可以访问。注意: friendly 不是java的关键字。
2.name变量:默认是 public static final。注意:public、static和final的顺序可以互换,没影响。
3.getId()方法:默认是public abstract。注意:这意味着没有结构体,也就是大括号及其内部。
----------------
详细参考:
http://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.4
可以查找关键语句:
1.Every interface is implicitly abstract
2.Every field declaration in the body of an interface is implicitly public, static, and final
3.Every method declaration in the body of an interface is implicitly public
4.Every method declaration in the body of an interface is implicitly abstract, so its body is always represented by a semicolon, not a block