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
11 ответов
+ 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);
+ 1
thank u#david
+ 1
thank u man....it's too useful
0
but...how to get rid of that 5...instead of printing own input...
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.
0
can u please give me an example
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*/
0
May i ask another doubt
0
How to use multiple inputs in a program?
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);
0
It helps.....thank u