• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Static Methods

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ???
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic