Skip to content

Instantly share code, notes, and snippets.

@kasramp
Created August 3, 2020 20:36
Show Gist options
  • Save kasramp/2987aa956072eb35150a0c0fd8d6c811 to your computer and use it in GitHub Desktop.
Save kasramp/2987aa956072eb35150a0c0fd8d6c811 to your computer and use it in GitHub Desktop.
Scanner input = new Scanner(System.in);
int x = 0;
try {
x = input.nextInt();
if(x < 1) {
throw new InputMismatchException();
}
} catch(InputMismatchException e) {
System.out.println("You input wrong number!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment