| Author |
Static Methods
|
Ray Dawson
Ranch Hand
Joined: Sep 16, 2011
Posts: 75
|
|
I want to implement an interface with some methods, but all of these methods are static.
The problem now is all of the code which I have is for Client side & all are static i.e. about 300 variables & 50 functions calls are all done as static. But now if I want to change these back to non-static I have to create numerous objects.
Is there anyway I can use static methods in interface ???
BTW, I'm using RMI Remote Interface, how can I use static methods in RMI ???
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12921
|
|
No, you can't declare static methods in interfaces, and then have classes that implement the interface with implementations of those methods. Static methods are not polymorphic: the rules for non-static methods don't work; you can't override static methods.
If your application is defined with lots of static methods and variables, then it is not at all object oriented, but very much procedural. And because of that you can't use features such as interfaces, because those only work well in an OO design. You'll have to redesign the application in an object oriented way.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: Static Methods
|
|
|