• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check if a particular method executed successfully?  RSS feed

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to check if a particular method executed successfully?

e.g.

public void task(){
//some task
}

if I call this method
object.task();

How will I come to know method executed successfully without any errors?.Is there any return value which can tell that there was some error while executing?
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Happy S Singh wrote:How will I come to know method executed successfully without any errors?.Is there any return value which can tell that there was some error while executing?

Sure, a boolean:
Winston
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or by exception(without return)
 
Ranch Hand
Posts: 187
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or Using try/catch block

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!