This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to call InnerClass method...Help..Urgent  RSS feed

 
sam patel
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How can i call a setName() method of the Inner class in below code.
Any help will be greatly appreciated.
Thanks.
public class EnclosingClass{
public class InnerClass{
private String name;
public String getName(){
return name;
}

public void setName(String name){
this.name = name;
}
}
}
 
sam patel
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out!
EnclosingClass ec = new EnclosingClass();
EnclosingClass.InnerClass ei = ec.new InnerClass();
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!