Eclipse,完成内部类 [英] Eclipse, completion of inner classes
本文介绍了Eclipse,完成内部类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个类 B
定义为 A的内部类
package hello;
class A {
static class B {
// ...
}
// ...
}
我正在编辑第三类 C
,而我需要声明一个 AB
对象:
I'm editing a third class C
, and I need to declare a A.B
object:
A.B something = new A.B(...);
如果我使用Eclipse的代码完成,我让Eclipse推断表达式的类型,我得到一些东西像这样:
If I use Eclipse's code completion, and I let Eclipse infer the type of the expression, I get something like this:
import hello.A;
import hello.A.B;
// ...
class C {
// ...
void foo() {
B something = new A.B(...);
}
}
有没有办法避免这种行为,并有eclipse使用 AB
而不是导入?
Is there a way to avoid this behavior and have eclipse using A.B
instead of importing it?
我想要的是:
import hello.A;
class C {
void foo() {
A.B something = new A.B(...);
}
}
推荐答案
与
package my.pack;
public class A {
public static class B {}
}
然后
package my.other.pack;
public class C {
my.pack.A.B myB = new my.pack.A.B();
}
但关注Eclipse,我想会尝试优化您的进口(我想你可以禁用它,但我不知道如何)。
but keep an eye on Eclipse, I think it will try to optimize your imports (I think you can disable it, but I don't know how).
这篇关于Eclipse,完成内部类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文