Reputation: 21986
It may seem a trivial question, but I've searched a lot and couldn't find an answer.
If I have a final field like this:
private final double DEGREES;
The variabile is written in caps because it's final, but shall also the getter method be in caps? So it would be getDEGREES or getDegress?
Upvotes: 0
Views: 1626
Reputation: 709
If that is a constant, you can expose it without a getter, as a static field. That seems to be the standard practice.
Upvotes: 3
Reputation: 44808
It should be getDegrees
. And, in my opinion, the only fields that should be in all caps are some static final
ones. Member fields that are final do not need to be in all caps.
/edit
Indeed, Oracle's Java code conventions say to only to have static final
constants in all caps, all member variables should be in lowerCamelCase.
Upvotes: 9