I wrote a method that asks the user to input a name, but I don't want it equal to the compName
and I don't want the user's input to be blank. I have humanName.equals("")
but that will only make sure that the name isn't "". It could still be one or more blank spaces. I need there to be atleast one character there. I can't figure out how to go about doing this.
public String getHumanName(String compName){
System.out.println("Enter a name for the human player: ");
String humanName = scan.nextLine();
while(humanName.equals(compName) || humanName.equals("")){
System.out.println("The human player cannot have the same name as the computer player or be blank. Enter a new name for the human player: ");
humanName = scan.nextLine();
}
return humanName;
}