• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
16 views

Problem :

I am getting bellow error when I try to use Integer.parseInt() with a single char

exception in thread "main" java.lang.numberformatexception: for input string: "s"

by (6.9k points)  
edited by

1 Answer

0 votes

Solution:

To parse any string to a number you should have valid number into the string.

But your S is not a number.

String s = "s"; 
System.out.println((char) Integer.parseInt(s));

It should be something like bellow code:

String s = "400";
System.out.println((char) Integer.parseInt(s));
by (30.3k points)  
edited by
...