Q:

Eclipse giving uninitialized compile time error when initialization occurs inside try/catch

I'm having trouble with a block of code that is telling me that a variable is not initialized even though I initialized it within a try/catch block. 
The code I have is:
public String doSomething(String input1, String input2) {
    CustomizedObject myobject = new CustomizedObject();
    try {
        Output out = (Output) myobject.getOutput();
    } catch (IOException e) {
        System.err.println("Error: " + e.getMessage());
    }
    return out.doSomethingString(input1, input2);
}

However, it is saying that I need to create a local variable "out."  
The code for my CustomizedObject is below:
public class CustomizedObject {

   private String attribute;

   public CustomizedObject() {
        attribute = "awesome";
   }

   public String getOutput() throws IOException {
       //.....code doing some stuff......
       return attribute;
   }
}

A:

You can't initialize the Output out inside the try/catch block.  Try the following:
public String doSomething(String input1, String input2) {
    CustomizedObject myobject = new CustomizedObject();
    Output out = null;
    try {
        out = (Output) myobject.getOutput();
    } catch (IOException e) {
        System.err.println("Error: " + e.getMessage());
    }
    return out.doSomethingString(input1, input2);
}

Note, that the above code will throw a NullPointerException if the IOException is thrown; so you probably don't want to out.doSomething if out == null.