java.lang.String.split()

Ads
 

java.lang.String.split()

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.

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

Ads

Ads