import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; public class trycatch { public int tryit() { try { System.out.println("In try"); throw new IOException(); } catch( IOException e ) { System.out.println("In catch"); return(1); } finally { System.out.println("In finally"); return(2); } } public static void main( String argv[] ) throws IOException { byte b[] = new byte[256]; int number; trycatch tc = new trycatch(); System.out.println( tc.tryit() ); while(true) { try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in) ); System.out.print("Enter number: "); number = Integer.parseInt(in.readLine()); break; } catch(NumberFormatException e) { System.out.println("Illegal number"); } finally { System.out.println("In the finally block"); } } System.out.printf("number is %d\n", number); } }