+ 3

How can i get a user input in my program?

how it is work?

26th Aug 2017, 1:14 AM
Mannu Joshi
Mannu Joshi - avatar
4 Answers
+ 12
public class Program { public static void main(String[] args) { int num = new java.util.Scanner(System.in).nextInt(); //used for inputting System.out.println(num); } } explained in the java course
26th Aug 2017, 1:29 AM
P R
P R - avatar
+ 4
import java. util. Scanner;/*import pkg of scanner*\ Scanner sc= new Scanner(System.in);/*object of scanner *\ x=sc.nextInt();/*for take input*\
18th Jan 2018, 12:30 PM
Akash
Akash - avatar
+ 1
Better use Scanner or Buffered Reader. Here are some examples. Scanner: https://code.sololearn.com/cr62Dl7fsMDv/?ref=app Buffered Reader: https://code.sololearn.com/crLzBq1OHLpQ/?ref=app
26th Aug 2017, 5:01 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
+ 1
there are several ways to achieve this like you can use the scanner method or use string x=JOptionpane.showInputDialog("your message");
19th Jan 2018, 3:49 PM
Arman joshi
Arman joshi - avatar