6 Answers
New Answerlets say you have a string String str = "Hello World!"; Scanner scan = new Scanner (str); scan.next (); vs scan.nextLine (); scan.nextLine () would give: Hello World! while scan.next () would give: Hello nextLine gives the whole line, which next only gives the next word
yes. the line could include integers and decimal numbers, except it would be returned as a string and in the case of only next (), even if it is an integer, it will be converted to a string, unless you do nextInt ()
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message