+ 1

How do you use user-input in your code?

How can you do this (From Javascript) in Java? var x = prompt("enter") I tried using the Scanner to get input but it says Int and Scanner are not the same

22nd May 2018, 2:23 AM
koala 🐨
koala 🐨 - avatar
2 odpowiedzi
+ 4
This is the equivalent Java: Scanner scan = new Scanner(System.in); System.out.print("enter"); String x = scan.nextLine(); For this JavaScript: var x = parseInt(prompt("enter")); This Java: Scanner scan = new Scanner(System.in); System.out.print("enter"); int x = scan.nextInt();
22nd May 2018, 3:21 AM
John Wells
John Wells - avatar
+ 4
Maybe you should study this lesson with more concentration. https://www.sololearn.com/learn/Java/2220/ Some other ways to get input are:- JoptionPane Class. This thread will help you with the following topic. https://www.sololearn.com/discuss/1262488/?ref=app
22nd May 2018, 3:04 AM
Akash Pal
Akash Pal - avatar