This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Do you mean Static Member classes? also known as Top-Level Nested Classes. These classes can be used as any regular Top level classes. They can be instantiated without an outer instance associated with them and can also define both static and non-static members, like any top level package member. However they can also access Static members from the enclosing class. Zulfiqar Raza
A free-standing top level class cannot be static. A static class can exist only within the context of another class. Static InnerClasses are not associated with an instance of outer ( enclosing ) class.
Usually static member classes( aka nested class ) are used as helper classes for the enclosing class. Hope that helps! Ajith
[This message has been edited by Ajith Kallambella (edited November 08, 2000).]
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Ajith I have some doubts if the methods are IMPLICITLY STATIC. I read in Khalid Nested Top level classes can have both static and non static methods. I tried it out
Correct me if I am wrong. Subha
Ajith Kallambella
Sheriff
Joined: Mar 17, 2000
Posts: 5782
posted
0
Yes, you are right and my wordings were confusing I have edited my post to make it clearer Thanks! Ajith
Subha, I have a doubt regarding your example, Here yu r calling a non static method in the main which is static, Is this valid? I mean by calling it even through object reference i.e o1.nonstaticmethod().......... I cant understand this, can yu explain it more clearly... Hope I dont sound so silly.
Shalini, a static method can access member variables or methods only thru a reference to an object, so this is perfectly legal and makes sense as well. HTH Shashi