【问题标题】:What's the difference between navigating to Declaration, Type Declaration, Implementation in IntelliJ IDEA?在 IntelliJ IDEA 中导航到声明、类型声明、实现有什么区别?
【发布时间】:2019-10-23 10:54:00
【问题描述】:

The official documentation 我不清楚要提取它们之间的真正区别。 为了更容易理解,有人可以举一个例子或场景吗?

【问题讨论】:

标签: java debugging intellij-idea navigation


【解决方案1】:

考虑以下示例代码。您的光标位于m.aMethod(); 中的m 或同一行中的aMethod

Main.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
  }
}

MyInterface.java

public interface MyInterface {
//               ^2
  public void aMethod();
//            ^3
}

【讨论】:

  • 对不起先生,但是为什么m.aMethod();两行行?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-21
相关资源
最近更新 更多