Can't I get string as input using this method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can't I get string as input using this method

Scanner sc = new Scanner(System.in) String s = sc.nextLine();

22nd May 2020, 1:03 PM
Rupali Tomar
Rupali Tomar - avatar
3 Answers
+ 3
Scanner sc = new Scanner(System.in) ; //ask question String word = sc.nextLine(); //print it System.out.println("user typed: " + word) ;
22nd May 2020, 1:28 PM
KingDaniel2004
KingDaniel2004 - avatar
+ 1
Is there at first line: import java.util.Scanner; ?
22nd May 2020, 1:50 PM
Igor Kostrikin
Igor Kostrikin - avatar
0
No it's not just a word
22nd May 2020, 1:18 PM
Rupali Tomar
Rupali Tomar - avatar