This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes to divide a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "to divide a string" Watch "to divide a string" New topic

to divide a string

vijay umar
Ranch Hand

Joined: Mar 24, 2009
Posts: 100
how to divide a string into 3 parts and assign it to three different variables?
Rob Spoor

Joined: Oct 27, 2005
Posts: 19725

You can use String.split if you have a special separator. Another option is a combination of indexOf and substring. In both cases it's important to know where to split the String.

How To Ask Questions How To Answer Questions
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
On what basis do you want to split your string??
Consider Paul's rocket mass heater.
subject: to divide a string