• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inner class

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone run this program and tell me the output i am getting unresolved compilation problem.But in K&B book pg:643 it's copiled and gave the out put ?solve this problem...

code:

class MyOuter{
private int s=7;

public void makeinner(){
MyInner in=new MyInner();
in.seeouter();

}
public class MyInner()
{
public void seeouter(){
System.out.println("outer s:"+s);
System.out.println("inner ref is:"+this);
System.out.println("outer ref is:"+MyOuter.this);
}
}
public static void main(String a[]){
MyOuter.MyInner in=new MyOuter().new MyInner();
in.seeouter();
}

Thanks in advance....
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why have you got brackets after inner class declaration?

public class MyInner() <--
[ October 03, 2007: Message edited by: suresh mulagala ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(Parentheses)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic