+ 1
How to get user input as integers
I could not use integers in the scanner example given. Please tell me how to
2 Respuestas
+ 2
import java.util.Scanner;
public class Main{
private static Scanner sc;
public static void main (String[] arts){
Scanner sc = new Scanner(System.in);
int x;//this is to initilized the varible location;
System.out.println("Enter a number: ");
x = sc.nextInt();//the nextInt is used to store interger varibles
System.out.println(x);
}
}
+ 1
Scanner sc=new Scanner(System.in);
System.out.println("input plzz");
int a=sc.nextInt(); // taking input as integer.