• Post Reply Bookmark Topic Watch Topic
  • New Topic

static methods  RSS feed

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • 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
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
  • 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 ]
 
Chandra Sekhar
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • 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
 
Oneal Shaha
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!