0

Hey...guys..I have a doubt...How to call the input in java?I am coding....the program compiles int x=5...or something..How to co

7th Jul 2017, 7:50 AM
Mr.kk
Mr.kk - avatar
11 Respostas
+ 1
/*You need to import scanner.. You have to put the "Import scanner part right at the top of the page and the rest below class*/ Import java.util.Scanner; int x; Scanner scan = new Scanner(System.in); x = scan.nextInt(); System.out.println(x);
7th Jul 2017, 8:08 AM
D_Stark
D_Stark - avatar
+ 1
thank u#david
7th Jul 2017, 10:07 AM
Mr.kk
Mr.kk - avatar
+ 1
thank u man....it's too useful
7th Jul 2017, 10:46 AM
Mr.kk
Mr.kk - avatar
0
but...how to get rid of that 5...instead of printing own input...
7th Jul 2017, 8:12 AM
Mr.kk
Mr.kk - avatar
0
int x; <<<< has no value int x = 5; <<<< x now has a value of 5 if you use scanner your input will give your x a value and print out.
7th Jul 2017, 9:54 AM
D_Stark
D_Stark - avatar
0
can u please give me an example
7th Jul 2017, 9:55 AM
Mr.kk
Mr.kk - avatar
0
int x = 5; System.out.println(x); /*output is 5 If you have multiple ints*/ int x = 5; int y = 10; int z = 25; System.out.println(x + y + z); /*output is 40 or with "Scanner" which lets the user input the ints value*/ Scanner scan = new Scanner(System.in); int x = scan.nextInt(); System.out.println(x); /*user inputs 255 output 255*/ /*hope that helps juat copy this text and paste in playground use only one statement at a time*/
7th Jul 2017, 10:05 AM
D_Stark
D_Stark - avatar
0
May i ask another doubt
7th Jul 2017, 10:07 AM
Mr.kk
Mr.kk - avatar
0
How to use multiple inputs in a program?
7th Jul 2017, 10:08 AM
Mr.kk
Mr.kk - avatar
0
/*When the input window appears input first int press enter to enter 2nd int , press enter to input 3rd int then run program hope that helps*/ Scanner scan = new Scanner(System.in); int x,y,z; x = scan.nextInt(); y = scan.nextInt(); z = scan.nextInt(); System.out.println(x + y + z);
7th Jul 2017, 10:21 AM
D_Stark
D_Stark - avatar
0
It helps.....thank u
7th Jul 2017, 10:22 AM
Mr.kk
Mr.kk - avatar