I have learnt that static nested class should be accessed like a field of outer class(line 2). But even instantiating the inner class directly worked (line 1). Can you please help me understand?
public class OuterClass { public OuterClass() { Report rp = new Report(); // line 1 OuterClass.Report rp1 = new OuterClass.Report(); // line 2 } protected static class Report() { public Report(){} } }
OuterClass. It's when you're accessing an exposed inner class from outside the containing class that you need to qualify it.