Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
try-catch replacement
import java.util.Scanner;
class MyThing {
public static void main(String[] args) {
Scanner x = new Scanner(System.in);
try {
int myNumber = x.nextInt();
}
catch (Exception lol) {
System.out.println("Enter a valid number");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.