File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes try...catch ...return Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "try...catch ...return" Watch "try...catch ...return" New topic
Author

try...catch ...return

sonny kher
Ranch Hand

Joined: Nov 06, 2001
Posts: 83
If I were to return a boolean value from a method, and this value is false in case there is an exception thrown in the method(that is being called) how do i do it?
public boolean methodA(){
try{
...
}catch(Exception e){}
return true;
}
will this automatically return false when there is an exception inside the try...catch block?
[ October 21, 2002: Message edited by: sonny kher ]

_ __________________ _ <br />RHCE<br />SCJP<br />??:-(
Chad McGowan
Ranch Hand

Joined: May 10, 2001
Posts: 265
Originally posted by sonny kher:
If I were to return a boolean value from a method, and this value is false in case there is an exception thrown in the method(that is being called) how do i do it?
public boolean methodA(){
try{
...
}catch(Exception e){}
return true;
}
will this automatically return false when there is an exception inside the try...catch block?
[ October 21, 2002: Message edited by: sonny kher ]

No, try this code instead:
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Chad McGowan:

or


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Are you trying to prod us into a multiple v. single exit point discussion?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Dirk Schreckmann:
Are you trying to prod us into a multiple v. single exit point discussion?

No, just providing alternatives. Are you?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Hmm... maybe...
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Dirk Schreckmann:
Hmm... maybe...

So, tell us when you came to a decision...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: try...catch ...return