Class B extends Class A, Class A has a variable named K, I have a static Class named "K" also. Is there a way inside class B to favor using t开发者_StackOverflow社区he static class K over the inherited variable K?
(I am working with decompiled code that was obfuscated, I cannot rename either of the versions of K)
You may need to refer to the class K
with its full name, ie myPackage.K
Since K is in the default package, I think your only options will be to refer to class K using reflection or else write a class to wrap K so you can use a different name. Or if you're after some static members of K, you could use static imports to get at them, too.
Does this work?
class A {
int X;
}
class B extends A {
static class X {}
void foo() {
X = 5; // A.X variable
B.X x = new B.X(); // B.X nested class
}
}
精彩评论