First Input
import java.util.Scanner;
public class Input
public class Input
{
public static void main(String args[])
{
Scanner input= new Scanner(System.in);
int var;
System.out.println("Enter any Integer: ");
var = input.nextInt();
System.out.println("Your Entered: "+var);
}
}
"input.nextInt()" is used to specify that the input we will be taking is an Integer value. You can also try it with other data types like Double, Float, etc.
To take any string value use "input.nextLine()"
Note: input IS ANY VARIABLE YOU CAN NAME IT YOURSELFE.
No comments:
Post a Comment