The official documentation 我不清楚要提取它们之间的真正差异。 为了更容易理解,有人可以举一个例子或场景吗?
答案 0 :(得分:3)
请考虑以下示例代码。光标位于m
的{{1}}或同一行的m.aMethod();
处。
Main.java
aMethod
MyInterface.java
public class Main implements MyInterface {
public static final void main(String args []) {
MyInterface m = new Main();
// ^1
m.aMethod();
// ^ Declarations will bring you to 1, the declaration of the variable (m)
// Type Declaration will bring you to 2, the declaration of the type of the variable (MyInterface)
m.aMethod();
// ^ Declaration will bring you to 3, the declaration of the method in the type (MyInterface) of the variable
// Implementation(s) will bring you to 4, the declaration of the method implementing the interface method
}
public void aMethod() {
// ^4
}
}