×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: William Chalifoux
Added: Mar 17, 2021 4:12 PM
Modified: Mar 17, 2021 5:55 PM
Views: 4805
Tags: no tags
  1. int number=0;
  2.         String str="32";
  3.         try{
  4.             System.out.println("Please enter the integer: ");
  5.             input.nextLine();
  6.             str=input.nextLine();
  7.             number=Integer.parseInt(str);
  8.            
  9.         }
  10.         catch (IllegalArgumentException e3){
  11.             System.out.println("Bad number format.");
  12.         }
  13.         catch (NumberFormatException e4){
  14.             System.out.println(str+" is not a number.");
  15.         }