Java Scanner String input

前端 未结 5 1324
遇见更好的自我
遇见更好的自我 2020-12-05 11:02

I\'m writing a program that uses an Event class, which has in it an instance of a calendar, and a description of type String. The method to create an event uses a Scanner t

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 11:15

    use this to clear the previous keyboard buffer before scanning the string it will solve your problem scanner.nextLine();//this is to clear the keyboard buffer

提交回复
热议问题