Can anyone tell me any simple method of using scanner | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone tell me any simple method of using scanner

Can anyone tell me any simple method of using scanner in java to get input from a user because the one in tutorial is very complex

19th May 2020, 4:37 AM
Abdul Malik
Abdul Malik - avatar
2 Answers
+ 3
//this is simplest way consume less lines and less declaration. import java.util.Scanner; class MyClass { public static void main(String[] args) { String input = new Scanner(System.in).nextLine(); System.out.println(input); } }
19th May 2020, 5:22 AM
Abhay Kalsi
Abhay Kalsi - avatar