java code to input an integer number only
static Scanner sc = new Scanner(System.in);
public static int Input(String mess){
int x=0;
while(true){
try{
System.out.println(mess);
x= Integer.parseInt(sc.nextLine().trim());
break;
}
catch(Exception e){
System.out.println("Error!Pls input integer number.");
}
}
return x;
}
public static void main(String[] args){
int Input=Input("Enter integer:");