I do have one validation issue and I don't know how to continue. The thing is that I am already checking if a string is empty (I guess) but it does not repeat the action.
I want the user types to be correct but it displays Please try again and after that it continues to my next statement about the team description. Any ideas?
System.out.println("Enter the name of the team : ");
team1.setTeamName(scanner.nextLine())
System.out.println("Enter the description of the team : ");
public void setTeamName(String teamName) {
if (!isNullOrEmpty(teamName)) {
this.teamName = teamName;
} else {
System.out.println("Team name can't bee empty");
System.out.println("Please try again");
public static boolean isNullOrEmpty(String str) {
if (str != null && !str.trim().isEmpty()) {
return false;
} else {
return true;
}
whileloop until the condition is satisfied, e.g.while(isNullOrEmpty(inputVariableHere){ // scanner code here ...`