public
System.out.println(X.Y.Z);
}
}
class
X {
}
}
class
C {
String
Z = "White";
}
What Does It Print? Do not run it in eclipse and tell me the answer. I need to know why as well?
Ans: White
Reason :Outer static variable priority is higher than inner static variable..
You're hiding the class Y with a static instance of C named Y. The class Y is still there and can be used.
Try:
System.out.println(X.Y.Z);
System.out.println((new X.Y()).Z);
The output should be:
White
Black
No comments:
Post a Comment