I think there is no difference between in the following:
MyOuter.MyInner i1 = new MyInner();
MyInner i2 = new MyInner();
I just want to confirm, because in the book I'm studying, the authors only teach the first way.
Joined: Dec 16, 2008
Either of those two ways is fine when you want to instantiate a static inner class from within its enclosing class. If you are going to instantiate a static inner class from outside the enclosing class, then you need to use the first form.
All code in my posts, unless a source is explicitly mentioned, is my own.
Joined: Feb 22, 2009
That's fine if your instantiating the class from within the enclosing class. Otherwise, you'd use:
And, if the class is static
Joined: Mar 04, 2009
Ryan Beckett wrote:That's fine if your instantiating the class from within the enclosing class. Otherwise, you'd use:
It is possible to instantiate a regular inner class this way from other classes.