Assign final variable in a try block

Posted by Bart van Heukelom on Stack Overflow See other posts from Stack Overflow or by Bart van Heukelom
Published on 2010-06-15T12:39:06Z Indexed on 2010/06/15 12:42 UTC
Read the original article Hit count: 261

Filed under:
|
|

Very short question: Is there a more elegant way to do this:

Object tmp;
try {
 tmp = somethingThatCanFail();
} catch (Fail f) {
 tmp = null;
}
final Object myObject = tmp;

© Stack Overflow or respective owner

Related posts about java

Related posts about try-catch