I think there is no difference between in the following:
MyOuter.MyInner i1 = new MyInner();
and
MyInner i2 = new MyInner();
I just want to confirm, because in the book I'm studying, the authors only teach the first way.
Thanks.
Ruben Soto
Ranch Hand
Joined: Dec 16, 2008
Posts: 1032
posted
0
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.
Ryan Beckett
Ranch Hand
Joined: Feb 22, 2009
Posts: 192
posted
0
That's fine if your instantiating the class from within the enclosing class. Otherwise, you'd use:
or
And, if the class is static
Leandro Coutinho
Ranch Hand
Joined: Mar 04, 2009
Posts: 415
posted
0
Thanks!
Ryan Beckett wrote:That's fine if your instantiating the class from within the enclosing class. Otherwise, you'd use:
or
It is possible to instantiate a regular inner class this way from other classes.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: (Inner Classes) MyOuter.MyInner vs MyInner