This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes static method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static method" Watch "static method" New topic
Author

static method

manas ranjan mandal
Ranch Hand

Joined: Apr 02, 2008
Posts: 97
hi i want to know that can i declare static method inside abstract class?
thanks in advance
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

What would prevent you from doing so ? (please consider asking this kind of question to the beginner forum).


[My Blog]
All roads lead to JavaRanch
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
I agree with Christopher this sounds like a beginner's question.

You implement a static method exactly the same way in any class; remember you can't override static methods; look at this FAQ, and ask again if there's anything you don't understand.
anu kuntala
Greenhorn

Joined: Sep 25, 2008
Posts: 17
Hi Manas,
Yes we can declare static methods in Abstract classes. You won't get any compiler error. But you cannot declare a method as both abstract and static. Because static methods cannot be overriden.

Regards,
Anu
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: static method