File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes static problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static problem" Watch "static problem" New topic

static problem

geet kaur
Ranch Hand

Joined: Sep 03, 2008
Posts: 79
why can't we declare abstract methods as static...?i know that we can't ...but don't know the exact reason for it...please help!
Henry Wong

Joined: Sep 28, 2004
Posts: 20370

Static methods can't be overriden, so it really doesn't make sense to declare a static method as abstract, as there is no way to define it by subclassing.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Well, in short, because in Java, abstract method implementations are looked up at runtime by checking the exact type of the object the method is called on. Since static methods are called without reference to an object -- i.e., you can call them as ClassName.methodName(), with no object involved -- there would be no way to figure out which implementation you mean. Of course you could work out a system for doing this, but Java's creators wanted the language to stay simple, with relatively few rules for understanding its behavior.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: static problem
It's not a secret anymore!