File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Nested/Inner classes Example program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Nested/Inner classes Example program" Watch "Nested/Inner classes Example program" New topic

Nested/Inner classes Example program

hardikjava shah

Joined: Dec 12, 2005
Posts: 13
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

Joined: Jul 12, 2006
Posts: 135
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,<br />-Rancy
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Time to look at our JavaRanch Naming Policy again. Hardik, please remove the "java" from your display name.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: Nested/Inner classes Example program
It's not a secret anymore!