• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Code Convention issue

 
Raghda Ismail
Greenhorn
Posts: 23
  • 0
  • 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
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dharmendra for your help
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This old thread may provide more useful information.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic