Quantcast
Channel: User Federico klez Culloca - Stack Overflow
Viewing all articles
Browse latest Browse all 516

Answer by Federico klez Culloca for Why there is no scanner.nextline() method between two nextInt() methods

$
0
0

nextInt reads the next token in the scanner.

According to the documentation

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

And further down

The default whitespace delimiter used by a scanner is as recognized by Character.isWhitespace().

The documentation for Character.isWhitespace() says that it returns true if the given codepoint

[...][...] is '\n', U+000A LINE FEED.[...]

Which means that \n is a separator, thus it's not part of any token, so you don't need to skip it with a dummy call to nextLine()


Viewing all articles
Browse latest Browse all 516

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>