So ,it is all about convert the string into char
Not exactly. charAt is about extracting a particular single char from a String.
The chars in a Java String are numbered from 0 to (length of String -1).
charAt(n) gives you the char in position n in the String.
So if the String is "Hello", charAt(0) is 'H', charAt(1) is "e", charAt(4) is 'o'.
You need to extract a single char in this case because you can't do a switch on a String value.
JamesCherrill
... trying to help
8,516 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,455
Skill Endorsements: 30
Question Answered as of 3 Years Ago by
JamesCherrill,
quuba
and
nomemory