aspose file tools*
The moose likes Beginning Java and the fly likes Help wanted ! PLease explain what is try and catch use for . 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 » Java » Beginning Java
Bookmark "Help wanted ! PLease explain what is try and catch use for ." Watch "Help wanted ! PLease explain what is try and catch use for ." New topic
Author

Help wanted ! PLease explain what is try and catch use for .

Tom Salo
Greenhorn

Joined: Oct 28, 2002
Posts: 7
As the topic said, Could anyone please explain what is try and catch in Java means please.
Also is that the catch always will be use after we use try ?
e.g
try
{
// Some code here
}
catch
{
// Some Code here
}
James Chegwidden
Author
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
Try /catch is used to handle exceptions.

Try must always be in tandem with either a catch and/or a finally. It cannot be alone.


Author and Instructor, my book
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Try means "execute the following code. If there is a problem look in the associated catch blocks to see how to handle the problem"
Catch means "if this is the problem that you ran into, this is what you should do about it". Normally this includes formatting some sort of message to the user or the console.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
When I began to learn about Exceptions in Java, I read (and reread a few times):
  • The Exceptions section of Sun's Java Tutorial
  • Chapter 10 of Bruce Eckel's Thinking In Java book (available as a free download through BruceEckel.com)
  • Chapters 80 and 81 of Bradley Kjell's Introduction to Computer Science using Java
  • Good Luck.


    [How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Help wanted ! PLease explain what is try and catch use for .