File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes String indexing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String indexing" Watch "String indexing" New topic
Author

String indexing

Brian Turner
Greenhorn

Joined: Mar 18, 2002
Posts: 4
Can someone tell me how to extract single caharacter from a a string?
for example: I have an String array of 9 digit numbers entered at the command line. I want to extract each of the 9 numbers from he string in each cell of the array and place them into another array singly.
command line entry String args[] in main = 123456789,987654321...
first command line number 123456789 goes into an int array
[0] = 1
[1] = 2
[2] = 3...
Thanks,
Brian Turner
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Brian,
The method String.charAt(int index) should do what you want.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
You can also convert the String into a char array using the toCharArray() method.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String indexing
 
Similar Threads
Random Numbers II
simple sorting algorithm
When to use new String("") against string literal
object creation in GC
Multidimensional arrays