wood burning stoves 2.0*
The moose likes Java in General and the fly likes Code Convention issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Code Convention issue" Watch "Code Convention issue" New topic
Author

Code Convention issue

Raghda Ismail
Greenhorn

Joined: Feb 22, 2009
Posts: 23
Hi every body,

I was reading code conventions from java.sun and i read these two lines and i really cannot understand them

Numerical constants (literals) should not be coded directly, except for -1, 0, and 1, which can
appear in a for loop as counter values.


i need to follow java standards in my current application and its important to me to understand it.

any help is appreciated.

Thanks in advance

Raghda
dharmendra gahlot
Ranch Hand

Joined: Apr 22, 2009
Posts: 54
Declare them as a constant and use.
example:-
public static final int LEVEL_ERROR = 3;
Create constant class and define required constants in it.
General: Constant Classes


Dharmendra Gahlot
SCJP-5.0 87%,SCWCD-5.0 92%
Raghda Ismail
Greenhorn

Joined: Feb 22, 2009
Posts: 23
Thanks dharmendra for your help
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38483
    
  23
This old thread may provide more useful information.
 
Don't get me started about those stupid light bulbs.
 
subject: Code Convention issue