Home Tutorials Java StringExamples java.lang.String.split()

Related Tutorials


 
 

Share on Google+Share on Google+

java.lang.String.split()

Advertisement
The split() method in Java is used to split the given string followed by regular expression in Java.

The split() method in Java is used to split the given string followed by regular expression in
Java. For example you can check the string for "," "/" etc.. and split the string into multiple
Java String Objects. See the example given below...

Syntax of Java split() method...
String[] split(String regex) Syntax
or
String[] split(String
regex, int limit)

a simple example of split() method in Java

public class example
{
public static void main(String[] args)
{
String data = "one two three four";
String[] items = data.split(" ");

for (String item : items)
{
System.out.println(item);
}
}
}

the Output is:
one
two
three
four

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 17, 2005

Related Tutorials

Discuss: java.lang.String.split()  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com