This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

can anyone answer the why it is

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Report post to moderator
public class TestClass {

/**
*
*/
public TestClass() {
super();
}

public boolean foo() throws ArithmeticException {
try {
int Nan = 1 / 0;
} catch (ArithmeticException e) {
throw e;
} finally {
return true;
}

}

public static void main(String[] args) {
TestClass test = new TestClass();
boolean result = false;
try {
result = test.foo();
} catch (ArithmeticException e) {
e.printStackTrace();
}

System.out.println(result);
}

}
if we run the above program it wil give "true" as output. can anyone answer
Why?
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Report post to moderator
Can anybody answer me, why this thread posted again when it is already there?
[ October 31, 2005: Message edited by: Chetan Parekh ]
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Report post to moderator


finally will always be executed no matter an exception occurs or not. This is the reason why method returned true.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Report post to moderator
Duplicate of this.
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!