0 votes

3 Answers

0 votes
by
How to split a string in java?

public class JavaExample{

   public static void main(String args[]){

String s = "" ,ab;gh,bc;pq#kk$bb"";

String[] str = s.split(""[,;#$]"");

//Total how many substrings? The array length

System.out.println(""Number of substrings: ""+str.length);

for (int i=0; i < str.length; i++) {

System.out.println(""Str[""+i+""]:""+str[i]);

}

   }

}
0 votes
by

We can use split(String regex) to split the String into String array based on the provided regular expression.

0 votes
by

public class Split {  public static void main(String args[])  {  String str = "Simplielearn";  String[] arrOfStr = str.split("e", 2);  for (String a : arrOfStr)  System.out.println(a);  }}

...