Month: February 2011

  • Exception Handling – The Catch Block should go Last

    I have just stumbled across a piece of code like this: Object getSomeValue() { Object value = null; try { value = errorProneOperation(); } catch (IOException e) { throw new IllegalStateException(e); } return value; } Now I find this really awkward. Why initialise something to null to keep the compiler happy? Surely you want to…