Here is the syntax of the String split method:
public String[] split(String regex) public String[] split(String regex, int limit)
public class Main { public static void main(String[] args) { String[] langs = "CSS,HTML,Java,Javascript".split(","); /* w ww.j a v a 2s .c om*/ for (String item : langs) { System.out.println(">" + item + "<"); } System.out.println(); langs = "CSS,HTML,Java,Javascript".split(",", 2); for (String item : langs) { System.out.println(">" + item + "<"); } System.out.println(); langs = "CSS,HTML,Java,Javascript".split(",", 20); for (String item : langs) { System.out.println(">" + item + "<"); } System.out.println(); langs = "CSS,HTML,Java,Javascript".split(",", 0); for (String item : langs) { System.out.println(">" + item + "<"); } } }