Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: use braces in for loop

...

Code Block
bgColor#ffcccc
byte[] b = new byte[4];
...
int result = 0;
for (int i = 0; i < 4; i++) {
  result = ((result << 8) | b[i]);
} 

Compliant Solution (Left Shift)

...

Code Block
bgColor#ccccff
byte[] b = new byte[4];
...
int result = 0;
for (int i = 0; i < 4; i++) {
  result = ((result << 8) | (b[i] & 0xff));
} 

Noncompliant Code Example (Compound Addition and Assignment)

...