I have code with this structure:
public void method() { Object o; try { o = new Object(); } catch (Exception e) {
I have several methods in which I have the same code in a catch block, so I want to extract it into a method to save some lines. My problem is that if I do this, I get a compiler error "Local variable o may not be initialized."
public void method() { Object o; try { o = new Object(); } catch (Exception e) { handleError(); }
Is there any workaround?
java exception compiler-errors unchecked
Luis sep
source share