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



java.lang.String.split()
Posted on: March 17, 2005 at 12:00 AM
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

Related Tags for java.lang.String.split():


More Tutorials from this section

Ask Questions?    Discuss: java.lang.String.split()  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.