I am pretty new to Java and have been trying to write some code so it will check the input received is only letters so no special characters or numbers can be put in.
So far I have gotten this far
System.out.println("Please enter your first name");
while (!scanner.hasNext("a-z")
{
System.out.println("This is not in letters only");
scanner.nextLine();
}
String firstname = scanner.nextLine();
int a = firstname.charAt(0);
This is clearly not working as it is just defining the input can only contain the characters a-z, I was hoping for a way to tell it it can only contain letters but have not been able to figure out yet how to.
Any help would be appreciated even a link to where I can read the proper commands and figure it out by myself :)
Thanks