This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes Code Convention issue Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply 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: 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
    
    4
This old thread may provide more useful information.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Code Convention issue
 
Similar Threads
Array question - enthuware
++ question
Increment
session handling problem
Array question - enthuware