So, this isn't just a problem that Java has. C++ had this same issue as well. Combining cin and getline in C++ results in the same behavior.
This also isn't really a problem, if you understand that it skips delimiter, reads, then stops at the next delimiter. nextLine is really the special one in the situation because it uses it's own delimiter separate from the scanner's and reads past it's delimiter and returns everything read, but the delimiter.
Agreed! I'm aware of how these tools work, but you have to keep in mind who this piece is targeting. Beginners don't usually have the bandwidth to tackle the intricacies of parsing when they just want to get some user input.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
So, this isn't just a problem that Java has. C++ had this same issue as well. Combining cin and getline in C++ results in the same behavior.
This also isn't really a problem, if you understand that it skips delimiter, reads, then stops at the next delimiter. nextLine is really the special one in the situation because it uses it's own delimiter separate from the scanner's and reads past it's delimiter and returns everything read, but the delimiter.
Agreed! I'm aware of how these tools work, but you have to keep in mind who this piece is targeting. Beginners don't usually have the bandwidth to tackle the intricacies of parsing when they just want to get some user input.