• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

inner class

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please see the following program

The result is inner,outer. I thought it will be inner, inner.Why does O.this.s print outer??

[This message has been edited by Sunita Vontel (edited August 31, 2000).]
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hello Sunita,
I hope you got how ,
System.out.println(s+ ","); is printing "inner,"
In the statement , System.out.println(O.this.s);
O.this refers to the inner
class object ,simply because the object that is invoking the method is of inner class type.
It is something like Outer.new Inner()
Hence it prints the string variable of th inner class. I hope it is clear.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
a similar example is given in "jamie jaworski" book.
here Outer.this.s refers to the s variable of the Outer class,
as Outer.this is an instance of Outer class that u are referring to here.
hope u got it, maha
 
Sunita Vontel
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks mahaadd
Hey karthik u said it is inner , inner but it prints inner,outer.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic