This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Code Convention issue  RSS feed

 
Raghda Ismail
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Raghda Ismail
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dharmendra for your help
 
Campbell Ritchie
Sheriff
Posts: 55292
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This old thread may provide more useful information.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!