[split] User input check 10-06-2013, 12:14 PM
#1
now it's me who have a question !!
in this code it will ask the user to enter his name :
what i wish to do is if the user enter a number instead of a name he gets an error and re-ask him to add his name i already know that i need to use while or do while for repeating the question but what to do to make it forbidden to use a number instead of a name ?
Code:
System.out.println("Hello there what's your name");
personsName = in.nextLine();
System.out.println("hello " + personsName);in this code it will ask the user to enter his name :
- if i enter blackeagle it will say then hello blackeagle
- if i enter 123456 it will say hello 123456
what i wish to do is if the user enter a number instead of a name he gets an error and re-ask him to add his name i already know that i need to use while or do while for repeating the question but what to do to make it forbidden to use a number instead of a name ?




![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
![[Image: 2YpkRjy.png]](http://i.imgur.com/2YpkRjy.png)
i was thinking about another way to do it cs i don't know how to use try and catch yet i'll be learning it soon so is there any other way to test it ?