Scanner only reads first word instead of line

后端 未结 5 1717
清歌不尽
清歌不尽 2020-12-17 15:58

In my current program one method asks the user to enter the description of a product as a String input. However, when I later attempt to print out this informat

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-17 16:50

    input.next() takes in the first whitsepace-delimited word of the input string. So by design it does what you've described. Try input.nextLine().

提交回复
热议问题