Java: Why Braces in Finally?
Why does finally have to have braces?
I can do this:
if(condition) statement;
and even this:
if(condition) statement;
else statements
And yet I cannot do this:
try {
statement;
} finally statement;
I am forced to do this:
try {
statement;
} finally {
statement;
}
Why Java why? I see why Rubyist's complain of too many braces
PS. Does that mean I am getting tired of Java? No. I think any healthy language needs constant criticism for improvement and continual health.
Filed under Java Software, Programming |
|
RSS 2.0 |
Trackback this Article
|
Email this Article
You may also like to read |






































August 31st, 2008 at 5:51 am
Sorry, did you just refer to this “omg I could be saving 2 characters” thing as “constant criticism for improvement and continual health” of a language?
And the lame “oh poor java, ruby is better”, you probably refer to typing ruby’s “end”, which is OMG 3 (three!) characters long, no kidding! Ruby must be totally stupid!
August 31st, 2008 at 6:42 am
It’s a inconvenience to me, albeit minor. The reference to Ruby was satirical, check my earlier posts on Ruby for context.
More than inconvenience however it goes against my sense of homogeneity of syntax. Any braces should ideally be optional, be it the brace around a method body or brace around if-else or try-catch-finally.