Blank input from scanner - java

后端 未结 4 1990
梦毁少年i
梦毁少年i 2020-12-18 11:16

What I\'m trying to do is if the user clicks on the enter key the program should throw a BadUserInputException. My problem is whenever I press the enter key it just puts me

4条回答
  •  温柔的废话
    2020-12-18 11:54

    Just use nextLine() method instead of next() while scanning the String and finally check the string using isEmpty() method. This Worked for me..

提交回复
热议问题