Saturday 21 June 2014

split (String regex)

public String[] split(String regex)
Splits this string around matches of the given regular expression.

class StringSplit{
 public static void main(String args[]){
  String s1 = "boo:and:foo";
  String s2[];
  
  s2 = s1.split(":");
  
  System.out.println("s1 = " + s1);
  System.out.println("s2 has");
  for(int i = 0; i < s2.length; i++)
   System.out.println(s2[i]);
 }
}

Output
s1 = boo:and:foo
s2 has
boo
and
foo





Prevoius                                                 Next                                                 Home

No comments:

Post a Comment