The local variable might not have been initialized – Detect unchecked exception throw within a method

You need to initialize local variables before they are used as below

public void method() {
    Object o=null;
    try {
        o = new Object();
    } catch (Exception e) {
        handleError();
    }
   doSomething(o); 
}

You will not get the compilation failure until you use local variable which was not initialized

Leave a Comment