Hello all,
I'm writing a program that gets an input string entered and I was wondering if there is an exception thrown so that the string is valid only if it is all letters. I can find exceptions thrown for only doubles, int.... as valid input but none for only letters. can anyone help me out?
hezfast2
0
Light Poster
Recommended Answers
Jump to PostHmmm, I don't recall any methods for that particular issue. However, there is a Throwable class (wich is the superclass for all exceptions in the Java Language) and an Exception class. This means that you can create your own exceptions.
Maybe you should take into consideration that approach.
Jump to Postdo your own input validation. Relying on Exceptions being thrown on bad input is usually not a good idea.
Jump to PostEven if you create your own Exception you will still need to implement some sort of validation in order to decide whether to throw the exception or not. So it up to you to decide, once you have made the validation, if it is necessary to throw an Exception or …
All 12 Replies
hezfast2
0
Light Poster
inzomniac
0
Newbie Poster
jwenting
1,889
duckman
Team Colleague
javaAddict
900
Nearly a Senior Poster
Team Colleague
Featured Poster
hezfast2
0
Light Poster
jwenting
1,889
duckman
Team Colleague
hezfast2
0
Light Poster
hezfast2
0
Light Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
hezfast2
0
Light Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
hezfast2
0
Light Poster
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.