wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Static Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static Methods" Watch "Static Methods" New topic
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static Methods
 
Similar Threads
Have an interfcae question
Applet to Servlet Communication with RMI
getConnection throwing NotSerializableException
RMI explination
Static Methods in RMI RemoteInterface