Created
April 9, 2014 13:58
-
-
Save edolopez/10273795 to your computer and use it in GitHub Desktop.
Try-Catch block in Java, a simple example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| import java.io.*; | |
| public class Strings { | |
| public static void main(String [] args) { | |
| Scanner input = new Scanner(System.in); | |
| try { | |
| input.nextInt(); | |
| System.out.println("Thanks"); | |
| } catch (InputMismatchException e) { | |
| System.err.println("Please no text :)"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment