void (String[] args) { String string; Exception exception; try { string = getString(); exception = null; } catch (SomeException e1) { string = null; exception = e1; } if (string != null) System.out.println ("Not null"); else exception.printStackTrace(); }