Java: Why Braces in Finally?
By Angsuman Chakraborty, Gaea News NetworkFriday, August 29, 2008
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.
February 17, 2010: 2:43 am
Thanks for sharing your thoughts. I enjoy reading your post and other people’s comments as it helps me understand terms and everything else better. |
jkarretero |
April 8, 2009: 5:10 pm
Totally agree. |
January 31, 2009: 7:17 am
your question is really interesting, but i think sun microsystem can only be able to answer this… |
August 31, 2008: 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. |
August 31, 2008: 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! |
Dentists Roseville