This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Splitting Strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Splitting Strings" Watch "Splitting Strings" New topic

Splitting Strings

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
Does anyone know how I can take a String and split it into 2 seperate strings? I have a name string and need it to be changed into a firstname string and second name string so the split should occur at the space.
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11924

you could use a stringTokenizer. check out the API here:
[ February 09, 2004: Message edited by: fred rosenberger ]

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Peyton McCullough
Ranch Hand

Joined: Feb 07, 2004
Posts: 31
The split() function will also work.
I agree. Here's the link:
subject: Splitting Strings
It's not a secret anymore!