Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- int poop = Integer.parseInt("Not a number");
- //All code happening in the try{} AFTER the parsing of the int will onloy execute if it worked, so if it was a number.
- }catch(Exception e){
- //This code will only execute if there was an exception. As I don't remember the exact Exception name, I just used Exception.
- //Which is like a joker as it will detect all exceptions. (It's probs something like InvalidNumberException)
- //Use this to print the error to the console (which you probs don't want but meh).
- e.printStackTrace();
- //If you don't use that line the error will still occur but not spam the console.
- //Now tell the player their numer was invalid:
- player.sendMessage("Not a number smartass");
- }
Advertisement
Add Comment
Please, Sign In to add comment