T
Tom Anderson
There are exceptions to this rule (pun intended)
Foo foo = null;
try {
foo = new Foo();
foo.doProcessing();
}
catch (FooException ex) {
doSomething(ex);
}
finally {
foo.cleanup();
}
In this case you have to initialize the variable foo.
No, because you should just write it like this:
Foo foo = new Foo();
try {
foo.doProcessing();
}
catch (FooException ex) {
doSomething(ex);
}
finally {
foo.cleanup();
}
If new Foo() can also throw an exception, then wrap that whole lot in a
try-catch or whatever.
tom