wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes problem of returning argument Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "problem of returning argument" Watch "problem of returning argument" New topic
Author

problem of returning argument

David George
Greenhorn

Joined: Aug 23, 2005
Posts: 10
public String[][] return()
{
try
{
---
return allRecords;
}
catch(RecordNotFoundException e)
{
---
return new String[0][0];
}
}

If Exception occurred,I have to return an unuseful String[][].Is it proper
for me to return a String[0][0]?Wait for your reply.Thank you very much.
Thomas Paul Bigbee
Ranch Hand

Joined: Jun 28, 2005
Posts: 71
You could return a null string, or an empty array, and the check it like the below, however, if an exception occurs you might not want to catch it, or you may want to re-throw it after it was caught (supplying additional information), regardless, if you are calling a method that can throw an exception, said method should be called from within a try catch block, its from within your catch block in the calling method that you should be doing any clean up.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem of returning argument