class NFE
{
public static void main(String[] args)
{
try
{
String s = "33";
int i = Integer.parseInt(s);
System.out.println("int value = " + i);
s = "computer";
i = Integer.parseInt(s);
// this line of code will never be reached//
System.out.println("int value = " + i);
}
catch (NumberFormatException e)
{
System.out.println("ERROR:"+e);
}
}
}
output:-
javac NFE.java
java NFE
int value = 33
ERROR:java.lang.NumberFormatException: For input string: "computer"
No comments:
Post a Comment