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
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.
Ask Questions? Discuss: java.lang.String.split()
Post your Comment