0

Getting input

Could you send me an example code "how to get input from the user, please? I received one explanation yesterday how to do it. I tried but it's not working. Here is the code: import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner obj=new Scanner (System.in); String name; System.out.println("Enter your name"); name=obj.nextLine(); System.out.println("Yor name is="+name); } }

16th Sep 2021, 1:51 PM
Mario
4 Réponses
+ 3
Your code is also working fine. If you're trying it on Sololearn, you need to provide your input on that alert box and hit the submit.
16th Sep 2021, 1:57 PM
Simba
Simba - avatar
+ 3
Where are you running the code ? Code works https://code.sololearn.com/cb7fjqjVvVgO/?ref=app
16th Sep 2021, 1:57 PM
Daljeet Singh
Daljeet Singh - avatar
+ 2
Mario, For next time please specify the language relevant to the question (and code) in the tags ☝ For the sake of context clarity ..
16th Sep 2021, 3:45 PM
Ipang
0
I'm running code on "Sololearn app"
16th Sep 2021, 2:49 PM
Mario