File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Referencing Inner Class Methods or Variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Referencing Inner Class Methods or Variables" Watch "Referencing Inner Class Methods or Variables" New topic
Author

Referencing Inner Class Methods or Variables

Thomas Markl
Ranch Hand

Joined: Mar 08, 2001
Posts: 192
Referencing Inner Class Methods or Variables
============================================
An method/variable of the instance inner class can only be invoked by a reference to the outer instance e. g.
Inner in1 = new Outer().new Inner();
There are two ways of referencing an inner class method/variable as I stated in the coding you can see down
there. Which way is the best to reference the inner class variable y?


Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
These two code samples are entirely equivalent.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Thomas Markl
Ranch Hand

Joined: Mar 08, 2001
Posts: 192
Hello,
I know that the functionality is entirely equivalent, but the coding to archieve this differs. So when apply simple method and when apply complex method?
Thomas
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
The code doesn't really differ. If you have a method that does nothing but invoke a constructor, you can just as well omit the method and call the constructor directly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Referencing Inner Class Methods or Variables