Java Reference
In-Depth Information
public class FadeToBlack {
static class Xy extends X.Y { }
public static void main(String[] args){
System.out.println(Xy.Z);
}
}
If you are using release 5.0 or a later release you can also solve the puzzle by using X.Y in the
extends clause of a type variable declaration:
public class FadeToBlack {
public static <T extends X.Y> void main(String[] args) {
System.out.println(T.Z);
}
}
In summary, to solve a problem caused by the obscuring of a type by a variable, rename the type
and variable in accordance with standard naming conventions, as discussed in Puzzle 68 . If this is
not possible, use the obscured type name in a context where only type names are allowed. With any
luck, you will never have to resort to such contortions, as most library authors are sane enough to
avoid the questionable practices that make them necessary. If, however, you do find yourself in this
situation, it's nice to know that there is a workaround.
< Day Day Up >
 
 
Search WWH ::




Custom Search