Tiny note about bitwise operator - '&' and '|'

These are called ‘Bitwise AND’ and ‘Bitwise Inclusive OR’.

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html

In most cases you do write something like this:

if (value != null && value.isValid) {
  ... do something
}

This allows you to check if the value is null then return and do nothing.

However, if you write something like this:

if (value != null & value.isValid) {
  ... do something
}

Then you just made your app to crash 100% due to NullPointerException if the value is null; single ampersand means that all expressions to be executed regardless of the first condition to be executed. It’s a shame, but I did not know about that until my co-workers reviewed my codes and told me about it.

Bitwise Inclusive OR does the same behavior as single ampersand as well.

I actually misunderstood this functionality as improved type checking that is introduced in Java SE 7 and later, which looks something like this:

catch (IOException | SQLException ex) {
    logger.log(ex);
    throw ex;
}

where originally, we were supposed to write like this:

catch (IOException ex) {
     logger.log(ex);
     throw ex;
catch (SQLException ex) {
     logger.log(ex);
     throw ex;
}