Java Reference
In-Depth Information
int bow;
// Position near the front of the boat
/* ... */
int stern; // Position near the back of the boat
Noncompliant Code Example
Thisnoncompliantcodeexampleprintstheresultofaddingan
int
anda
long
value,even
though it may appear that two integers (
11111)
are being added:
public class Visual {
public static void main(String[] args) {
System.out.println(11111 + 1111l);
}
}
Compliant Solution
Thiscompliantsolutionusesanuppercase
L
(
long
)insteadoflowercase
l
todisambiguate
the visual appearance of the second integer. Its behavior is the same as that of the non-
compliant code example, but the programmer's intent is clear:
public class Visual {
public static void main(String[] args) {
System.out.println(11111 + 1111L);
}
}
Noncompliant Code Example
This noncompliant code example mixes decimal values and octal values while storing
them in an array:
int[] array = new int[3];
void exampleFunction() {
array[0] = 2719;