What's the difference between next() and nextLine() methods from Scanner class?

后端 未结 14 2001
你的背包
你的背包 2020-11-21 05:32

What is the main difference between next() and nextLine()?
My main goal is to read the all text using a Scanner which may be \"con

14条回答
  •  旧巷少年郎
    2020-11-21 06:38

    From the documentation for Scanner:

    A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace.

    From the documentation for next():

    A complete token is preceded and followed by input that matches the delimiter pattern.

提交回复
热议问题