+ 1

How to accept a complete sentance as input in java

i tried using the following code but the code is excepting only the first word and not the entire sentance . plssss help here is the code Scanner scan =new Scanner(system.in); String s= scan.next(); system.out println("string is ",+s); my input: hello world output: hello

22nd Mar 2017, 1:12 AM
NIKHIL MURARKA
3 Respuestas
+ 18
I believe you will need nextline() instead of next() ?
22nd Mar 2017, 1:23 AM
Hatsy Rei
Hatsy Rei - avatar
+ 6
Use nextLine ()
22nd Mar 2017, 2:46 AM
Heng Jun Xi
Heng Jun Xi - avatar
+ 1
use nextLine() to read full
28th Mar 2017, 8:01 PM
Mohammed Salman Khan
Mohammed Salman Khan - avatar