CODSTA.LONG
Use `L' instead of `l' to express "long" integer constants
Description
This rule flags code where a long integer constant is indicated by `l' instead of by `L'.
Integer constants are "long" if they end in `L' or `l';. `L' is preferred over `l' because `l' (lowercase `L') can easily be confused with `1' (the number one).
Example
package CODSTA;
class LONG {
long getLongNumber () {
long temp = 23434l; // Is this 23434L or 234341?
return temp;
}
}
Repair
class LONG {
long getLongNumber () {
long temp = 23434L;
return temp;
}
}
Reference
Arnold, Ken, and Gosling, James The Java Programming Language. 2d ed. Addison Wesley, 1997, pp.108
|