Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Khalid's question on Inner class

 
aishwarya mathur
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Here "sunil" get printed.Can explain why?
 
Doyle Matt
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inner classes are no my specialty but here goes

new Example().new Inner().doIt();

what this one does is it:
first : creates and object of Example
second: using that object of Example it creates an inner object of Inner
third : using that inner object it calls the doIt function of the Inner object
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice that class Object, which your Example class inherits, does not have a member or method called new (I'm talking about the .new). It's a part of the syntax of the java Language which is understood by the compiler.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic