this is my code, it can validate single word but when i input example: John Smith the output is just John
package space;
import java.util.Scanner;
public class validate{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean cusloop=false;
String cusname="";
while(cusloop==false){
System.out.print("Enter customer name: ");
cusname=sc.next();
if(cusname.matches("[a-zA-Z ]+")){
cusloop=true;
}
else{
System.out.println("Invalid Input!");
System.out.println("Input Letters Only!");
}
}
}
}