Given this class definition:
class Outer { static class Inner { public final String text = "Inner"; } }
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?.
public class Main { public static void main(String []args) { System.out.println(/*CODE HERE*/); } }
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.