I am pretty new to Java and I was stuck when I was trying to check if the user input is texts (strings) and not numbers. hasNext(), next(), nextLine() doesn't necessarily check for strings, so I am not sure how it can be done.
import java.util.Scanner;
public class CalculateOne {
public static void main(String[] args) {
System.out.print("Enter a or b");
Scanner scan = new Scanner(System.in);
boolean isItString = scan.hasNextLine();
while (! isItString) {
System.out.print("Invalid Input! \n");
scan.next();
}
String type = scan.nextLine();
System.out.println("you chose "+type);
}
}