Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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

Code Convention issue

Raghda Ismail

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

dharmendra gahlot
Ranch Hand

Joined: Apr 22, 2009
Posts: 54
Declare them as a constant and use.
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

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

Joined: Oct 13, 2005
Posts: 46375
This old thread may provide more useful information.
I agree. Here's the link:
subject: Code Convention issue
It's not a secret anymore!