Skip to content

Instantly share code, notes, and snippets.

@edolopez
Created April 9, 2014 13:58
Show Gist options
  • Save edolopez/10273795 to your computer and use it in GitHub Desktop.
Save edolopez/10273795 to your computer and use it in GitHub Desktop.
Try-Catch block in Java, a simple example
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