dimanche 23 octobre 2016

Java-Checking whether user input smt or not

Hello assume that I have a scanner

Scanner s=new Scanner(System.in);
int a=s.nextInt();

and I want to get a number for a variable but user directly pressed enter without entering a number.How can I check this?I want to write "enter a number" if user didnt enter any number.

Aucun commentaire:

Enregistrer un commentaire