| Author |
Parsing Characters?
|
Sam Bluesman
Ranch Hand
Joined: Nov 21, 2004
Posts: 188
|
|
Lets say im reading a line from a text file. In the case on wanting to put integers that are in a string I read in into an integer, the following snippet of code works fine. obvisouly the emphasis is on the Integer.parseInt() Now, lets say i want to read in letters that are seperated by spaces that are to be placed into a char array called, say, letters. Is it possible to PARSE these in as characters into a char array or do these have to be passed in as STRINGS into a String array? Thanks [ November 02, 2005: Message edited by: Sam Bluesman ]
|
Moosey knows best
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24051
|
|
If "letter" is a one-character String, then to get that character as a 'char' you use the charAt() method: char c = letter.charAt(0); This method works for Strings of any length, of course.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Sam Bluesman
Ranch Hand
Joined: Nov 21, 2004
Posts: 188
|
|
|
Thanks. That worked just fine!
|
 |
 |
|
|
subject: Parsing Characters?
|
|
|