File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner Class

 
Nitin Bhagwat
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following code works fine, but why isit fails if comment on line 1 is removed and comment on line 2 is added?

 
Rituparno Pal
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Its simple, can't invoke a inner class constructor unless its not defined. For every class you define a .class file is created by the Java compiler. So when you call the constructor of 'first' class the corresponding can't be found. Its like using a undefined variable.
 
Nitin Bhagwat
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.

"can't invoke a inner class constructor unless its not defined"
"when you call the constructor of 'first' class the corresponding can't be found."

- Inner class is defined in outer class tst. If you run code as it is, it will compile fine. - So there is no proble of definition of innerclass and it's constructor (which is default).
 
Mike Gershman
Ranch Hand
Posts: 1272
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that while instance and class identifiers are in scope throughout the class definition, local method identifiers are only in scope from the point of definition to the end of the method (here I ignore hiding and overriding).

class first is not in scope at line 1 but is in scope at line 2.
 
Nitin Bhagwat
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mike !
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic