Results 1 to 3 of 3
Thread: Exception handling
- 11-10-2011, 04:27 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 5
- Rep Power
- 0
Exception handling
Hi guys, Basically i just wondered if someone could explain to me how it is possible to return to the start of the try block after an exception has been caught.
I have
try{
//method for user input
}
catch (exception definition) {
//exception message when user inputs wrong type of data etc
}
but id like it to return to the start of the try block to allow the user to re-enter the correct data... is this possible? please help,
greatly appreciated,
Moedig
- 11-10-2011, 09:16 PM #2
Re: Exception handling
There isn't a way to jump back up to a certain line of code. You'll need to use functions or loops to achieve what you want.
- 11-10-2011, 10:43 PM #3
Re: Exception handling
Example using a loop:
If the user input throws an exception then it will jump the line which marks the input as valid. Then it will go around the loop again.Java Code:declare a boolean while input is invalid { try { get user input which might throw exception flag input as valid } catch exception { display error message } }
Similar Threads
-
exception handling
By niksipandit in forum New To JavaReplies: 3Last Post: 09-22-2011, 02:25 PM -
Exception handling
By herat in forum New To JavaReplies: 1Last Post: 06-21-2011, 10:13 AM -
Exception Handling
By eLancaster in forum New To JavaReplies: 4Last Post: 02-20-2011, 12:00 AM -
Exception Handling
By liljester in forum New To JavaReplies: 4Last Post: 06-21-2010, 03:09 PM -
Exception Handling help
By MZA in forum New To JavaReplies: 3Last Post: 02-10-2010, 09:23 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks