1package com.devdaily.javasamples;
2
3public class ConvertStringToNumber {
4
5 public static void main(String[] args) {
6 try {
7 // intentional error
8 String s = "FOOBAR";
9 int i = Integer.parseInt(s);
10
11 // this line of code will never be reached
12 System.out.println("int value = " + i);
13 }
14 catch (NumberFormatException nfe) {
15 nfe.printStackTrace();
16 }
17 }
18
19}
20
1Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format.