Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: use && consistently in CS

...

Code Block
bgColor#ccccff
int array[]; // may be null
int i;       // may be an invalid index for array
if (array != null && i >= 0 && i < array.length && array[i] >= 0) {
  // handle array
} else {
  // handle error
}

...

Code Block
bgColor#ccccff
int array[]; // may be null
int i;       // may be a valid index for array
if (array!= null) {
  if (i >= 0 && i < array.length) {
    if (array[i] != -1) {
      // use array
    } else {
      // handle error
    }
  } else {
    // handle error
  }
} else {
  // handle error
}

...