Link to home
Start Free TrialLog in
Avatar of BrianMc1958
BrianMc1958

asked on

Use getters and setters on static fields?

Dear Experts,

Is there an "industry standard" for accessing static fields?  I normally use private fields with getters and setters now.  But in the case of static fields, is it worthwhile to bother?  It seems a lot simpler to just do:

String myString = MyClass.SOME_STATIC_FIELD;

and declare SOME_STATIC_FIELD to be public and final.

Thanks,
BrianMc1958
Avatar of sciuriware
sciuriware

The rules for static fields are exactly the same as for instance fields.
Access restrictions and checking of set-values are just the same!

;JOOP!
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial