+ 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
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();
+ 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