Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

what is the difference between sc.nextLine() and sc.next() in java

Their differences are...

next() can read the input only till the space. It can't read two words separated by space. Also, next() places the cursor in the same line after reading the input.

nextLine() reads input including space between the words (that is, it reads till the end of line 
). Once the input is read, nextLine() positions the cursor in the next line.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #difference #java
ADD COMMENT
Topic
Name
4+2 =