• Post Reply 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem of returning argument

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic