File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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: 45335
This old thread may provide more useful information.
I agree. Here's the link:
subject: Code Convention issue
jQuery in Action, 3rd edition