Enter your E-mail Address below for Free E-mail Alerts right Into your Inbox: -

Sunday

Advantages and Disadvantages of using Static Methods inside Class in Java

Advantages and Disadvantages of using Static Methods inside Class in Java

Advantages:


  1. Static methods are thread safe.
  2. Globally accessible
  3. Can be accessed by using Class Name.
Disadvantages:
  1. Static members are part of class and thus remain in memory till application terminates and can't be ever garbage collected. Using excess of static members sometime predicts that you fail to design your product and trying to cop of with static / procedural programming. It denotes that object oriented design is compromised. This can result in memory over flow.
  2. To synchronize need some more efforts.

No comments:

Post a Comment