| Author |
can a class be static?
|
santhoshkumar samala
Ranch Hand
Joined: Nov 12, 2003
Posts: 156
|
|
hello I am new to java can any body please tell me the answer for this Qn can a class be static? if not then why?
|
santhosh<br />SCJP,SCWCD
|
 |
Landon Blake
Ranch Hand
Joined: Dec 04, 2003
Posts: 121
|
|
Yes, a class can be static. This is done by creating the class with the "static" keyword in the class statement. Example: public static class MyClass{ Here is an article that explains which types of classes can and can't be declared as static: http://www.javaworld.com/javaworld/javaqa/1999-08/01-qa-static2.html I hope that helps. Landon [ May 06, 2004: Message edited by: Landon Blake ]
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
A top-level, outer class cannot be static. Only a class declared inside another class can be declared static. These are sometimes called nested top-level classes. [ May 06, 2004: Message edited by: Dirk Schreckmann ]
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
 |
|
|
subject: can a class be static?
|
|
|