Friday 1 September 2017

Java Scanner Class Methods

Cited from the Book Java How to Program

Method nextLine reads characters typed by the user until it encounters the newline character, then returns a String containing the characters up to, but not including, the newline.

Class Scanner also provides a similar method -- next -- that reads individual words. When the user presses Enter after typing input, method next reads characters until it encounters a white-space character (such as a space, tab or newline), then returns a String containing the characters up to, but not including, the white-space character (which is discarded).

nextDouble method returns a double value entered by the user.

No comments:

Post a Comment