• Post Reply Bookmark Topic Watch Topic
  • New Topic

avoid running final clouse  RSS feed

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there anyway to avoid running final cluse

 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
final what ??
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only by never leaving the try block. That can happen due to a never-ending loop, or by calling wait() on an object that is never notified, or by calling System.exit(), or via a JVM crash.
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happen when we return inside the try block?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i went for an interview.they ask me ?
I tried at home.But it is not compiling.
Anyway there is someway to avoiding final block.I heard somewhere.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interesting is this piece of code


It compiles just fine. And returns 1.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Samanthi perera wrote:no i went for an interview.they ask me ?
I tried at home.But it is not compiling.
Anyway there is someway to avoiding final block.I heard somewhere.


there is -> don't use it. Other than that only the ways Ernest mentioned.
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


if we use this then it means it doesn't return 0 to the user or method?
is it?
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep. Never use this form it simply doesn't make any sense. But it compiles. It will also show a warning upon compilation.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Samanthi perera wrote:

if we use this then it means it doesn't return 0 to the user or method?
is it?

Would it be that difficult to just *try* it?
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!