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

Nested/Inner classes Example program

 
hardikjava shah
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I created a small test program to learn Nested/Inner classes. Thought of sharing with you all. You can tweak it and see results for yourself. Also, let me know if you think I have missed anything.




[HENRY: Added Code Tags]
[ December 09, 2006: Message edited by: Henry Wong ]
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hardik,

Just want to do a little correction about the comment you wrote above the method
//Static inner class
static class staticnestedclass
{
void testmethod(){
System.out.println("Printing from static nester class!");}
}

The nested classes which are declared as static are NOT INNER classes. They are just termed as static nested classes.

Classes which fall under inner classes are:
nonstatic nested classes
local classes
anonymous class

The code you have written is good but I wanted to suggest you that you missed to show an example of local class nested in static method if I am not mistaken.

Thanks,
Rancy
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Time to look at our JavaRanch Naming Policy again. Hardik, please remove the "java" from your display name.
Thanks,
-Barry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic