I have a string that has the value of name:score. I want to split the string into two strings, string a with the value of name and str
name:score
a
name
$ cat Split.java
public class Split { public static void main(String argv[]) { String s = "a:b"; String res[] = s.split(":"); System.out.println(res.length); for (int i = 0; i < res.length; i++) System.out.println(res[i]); } }
$ java Split
2 a b