Java try/catch

This is a little example about try and catch in Java:

public class HelloWorld{
     public static void main(String []args){
        System.out.print("write your number: ");//Info text 
        String str = System.console().readLine();//read input
        int res = 0;
        try{
           res = Integer.parseInt(str); 
           res *= 2;
        }catch (Exception e){
            System.out.println("Error:"+e);
        }
        System.out.println("result:"+res);
     }
}

Output looks like:

sh-4.3# java -Xmx128M -Xms16M test                     
write your number: 2                                         
result:4  

                                                
sh-4.3# java -Xmx128M -Xms16M test                     
write your number: a                                         
Error:java.lang.NumberFormatException: For input string: "a" 
result:0