• 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: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a class what are the design perspective in which I would make my method as static?
As static methods would be in class level. So to access I wouldn't need to instantiat the bean.
But how does it helps and why should I need not instatiate a object to use its method.

Thanks,
aakash
 
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi aakash,

Static methods remind me of traditional methods in the c programming language. They can still be used that way, for instance, see how the methods in the Math class are all static.

But you cannot call instances of classes from static methods and that would cut out most of swing and awt.

Ed
[ August 30, 2004: Message edited by: Eddie Vanda ]
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Check this....

http://www.javaworld.com/javaworld/javaqa/2001-11/03-qa-1121-mrhappy.html

rgds
Chandrasekhar S.
SCJP
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The intension behind the static methods is that there may be some operations which are not instance specific and do not need any non-static members. Like the methods in the Math class. So if we make these methods static we can get rid of making new objects and allocating seperate memory for them.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic