Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class program1
- {
- public static void main(String args[])
- {
- Scanner scan = new Scanner(System.in);
- //If there's an error in the try{} block do catch{} block.
- //Instead of raising a weird error we simply just raise catch().
- try{
- System.out.print("Type in first number: ");
- scan.nextInt();
- }
- catch(Exception e)
- {
- System.out.print("Unable to complete.");
- }
- /*
- * In this case the user types a string
- * in to the input that scans the input.
- * That will raise an error. But instead of giving that
- * specific error we simply just execute the catch block.
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement