Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (10.2k points)
How do I parse a String value to a char type, in Java?

I know how to do it to int and double (for example Integer.parseInt("123")). Is there a class for Strings and Chars?

1 Answer

0 votes
by (46k points)

f your string contains exactly one character the simplest way to convert it to a character is probably to call the charAt method:

char c = s.charAt(0);

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 9, 2019 in Java by Anvi (10.2k points)

Browse Categories

...