| 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: 52
|
|
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: 32833
|
|
|
This old thread may provide more useful information.
|
 |
 |
|
|
subject: Code Convention issue
|
|
|