Preventing errors when typing a letter into a String
I would like general guidance on how to avoid an error when someone tries to type a letter into an integer from the scanner class. My program asks for a number, but if someone types a letter in it gives multiple errors and I would like to know how to avoid this.
I think I would use a try, catch, but I am not exactly sure how to implement that. What error do I put in the catch? Can I just use one statement for all errors?
I was thinking something like this
x = scanner.nextInt}
What do I put in the spot where I have exception?