I've got a program that takes an integer using Scanner's nextInt() method. If the user doesn't enter anything, my program ~!@#$%^&*()_ up.
I tried two things:
1.
int num = myScanenr.nextInt();
if(num==null)
System.exit(0);
this wouldn't compile because the type were incomparible
2.
Scanner myScanner = new Scanner(System.in);
if(myScanner==null)
System.exit(0);
this had no effect on my program
does the scanner take the input even
before nextInt() is called, or is my thinking in error?
how do I solve my problem about empty input?