Why nextLine() and not nextString() ?

Consider this: nextLine return everything until next endline (\n) in form of String. Would you not think that you will retrieve everything if it was called nextString? In that case you would be posting question “why nextString() stops at endline”

tl;dr it’s because it searches for endline (\n)

upd: on documenatation it refers to it as “skipped” part. I.e. cursor goes to next line and returns everything “skipped”. Default output is String, so you have it: everything skipped as String.

Leave a Comment