-
Junior Member
Catch string value error
How can I give the exception method if I entered a string value for a integer value? I mean the user asking to enter a integer value. But user entered a string value. How should I catch this error using exception? Can you give some examples?
-
Junior Member
Re: Catch string value error
Hi
Use Integer.parseInt(String obj) method.
If it gives exception in parsing,then u can catch it and give a message to the user about invalid data..
for example:
if user entered is "hello" instead of 56.
String val="hello".
int i=Integer.parseInt(val);
Regards,
Raghu
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules