This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how to depart String by Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to depart String by "space"" Watch "how to depart String by "space"" New topic
Author

how to depart String by "space"

marshal ma
Greenhorn

Joined: May 31, 2004
Posts: 23
I have a String like "it is good", I know the String is made of three words(two space between three words), I want to turn it to three String, like this:

String data1 = it;
String data2 = is;
String data3 = good;

How to do that easily?

Thanks,
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

The String.split() method is a very easy way to do exactly what you want.


[Jess in Action][AskingGoodQuestions]
marshal ma
Greenhorn

Joined: May 31, 2004
Posts: 23
Hi Ernest Friedman-Hill

Got it, I didn't know there is such a good method.

Thanks a lot,
Julien Grenier
Ranch Hand

Joined: Sep 01, 2005
Posts: 41
Lesson number one : Know your API
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to depart String by "space"
 
Similar Threads
JTextArea line break
how can i separate string?
String - remove more than one space between words
String confusion
Regex help