Consider the following program:
class Outer {/*from w w w. j av a 2 s.co m*/ static class Inner { public final String text = "Inner"; } } class Main { public static void main(String []args) { System.out.println(/*CODE HERE*/); } }
Which one of the following expressions when replaced for the text in place of the comment /*CODE HERE*/ will print the output "Inner" in console?.
Inner()
.textInner()
.textOuter()
.Inner.texta)
The correct way to access fields of the static inner class is to use the inner class instance along with the outer class, so new Outer.Inner()
. text will do the job.