Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes Clases and their methods? 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 » Java » Beginning Java
Bookmark "Clases and their methods?" Watch "Clases and their methods?" New topic

Clases and their methods?

Ahmer Arman

Joined: Nov 23, 2001
Posts: 6
Hi Java Friends,
If I declare any class static then what their methods will behave. do they behave like static methods or else.

Ahmer Arman

Ahmer Arman
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
The only type of clas you can declare as static is a nested class. A static inner class can be considered the same as a normal class so the methods in the class would be uneffected by the static modifier. Except that they would not be able to access member variables of the enclosing class because the class they are part of is a static member. In a sense it is like making all of the static inner classes methods static. But is becasue of the nature of the iner class not becasue of the static modifier on the class itself. Although it is due tot he static modifier that the class is static...
hope that helps

Sun Certified Programmer for the Java� 2 Platform

Bill Siggelkow
Ranch Hand

Joined: Jun 27, 2001
Posts: 57
You cannot declare a class to be static -- only methods and variables.

Bill Siggelkow
Jade Cove Solutions
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Bill, as mentioned by Dave, you can declare an inner class as static.
SCJP for the Java� 2 Platform

So much trouble in the world -- Bob Marley
Thomas Whalen
Ranch Hand

Joined: Aug 26, 2001
Posts: 123
never argue with the bartender, those chipped glasses don't always go straight to the trash can.

if you don't know, then ask. if you do know, then share. love is knowledge.
I agree. Here's the link:
subject: Clases and their methods?
jQuery in Action, 3rd edition