wood burning stoves
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to depart String by "space"" Watch "how to depart String by "space"" New topic

how to depart String by "space"

marshal ma

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?

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24193

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

[Jess in Action][AskingGoodQuestions]
marshal ma

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"
It's not a secret anymore!