Hi, so I'm new with Java and the programming thing. Here's my problem. I need to do an errortrap without using a loop and creating a method solely for errortrapping so I figured i need to use try and catch statements but I'm not sure how. Basically my problem is that I need to get a user input to proceed to another method and to exit. Say for example, the program requires you to input 'e' to exit and 'p' to proceed. Anything else would be an error. Can anyone give me an example?
Daigan
0
Junior Poster in Training
Recommended Answers
Jump to Postyou've mentioned everything you need to do.
is it necessary you throw an exception, do you just have to show an error message, ...
be a bit more clear, and show what you've tried so far.
Jump to Postwhat is c?
why are you putting a char into an integer?
why do you think an Exception will be thrown if you enter another value than 'p' or 'x'?
All 8 Replies
stultuske
1,116
Posting Maven
Featured Poster
Daigan
0
Junior Poster in Training
stultuske
1,116
Posting Maven
Featured Poster
Daigan
0
Junior Poster in Training
stultuske
1,116
Posting Maven
Featured Poster
Daigan
0
Junior Poster in Training
Slimmy
0
Junior Poster in Training
Daigan
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.