Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is the I get this error NumberFormatException when I run my code :

java.lang.NumberFormatException: For input string: "N/A"

    at java.lang.NumberFormatException.forInputString(Unknown Source)

    at java.lang.Integer.parseInt(Unknown Source)

    at java.lang.Integer.valueOf(Unknown Source)

    at java.util.TreeMap.compare(Unknown Source)

    at java.util.TreeMap.put(Unknown Source)

    at java.util.TreeSet.add(Unknown Source)`

Can anyone tell me why I’m getting the error and how to fix this? 

1 Answer

0 votes
by (19.7k points)

You get NumberFormatException, because “N/A” is not an integer when you try to parse it to an integer. Check the Exception handling below: 

try{

    int my_int = Integer.parseInt(input);

} catch(NumberFormatException ex){    

...

}

 If you want to learn more about Javathen go through this Java tutorial by Intellipaat for more insights. 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...