java - Can outclass specify inner class with InnerClassNameOuter directly rather than ClassName.InnerClassName -


in inner classes of thinking in java,

if want make object of inner class anywhere except within non-static method of outer class, must specify type of object outerclassname.innerclassname, seen in main().

but find use innerclassname directly still works in main.

   public class parcel2 {         class contents {             private int = 42;             public int value() { return i; }         }         class destination {             private string label;             destination(string whereto){                 label = whereto;             }             string readlabel(){ return label; }         }          public destination to(string s){             return new destination(s);         }          public static void main(string[] args){             parcel2 q = new parcel2();                /* destionation d = q.to("borneo");      still works.*/              parcel2.destination d = q.to("borneo");          }     } 


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -