Java - Write code to seperate a string On Comma

Requirements

Write code to seperate a string On Comma

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String string = "a,b,c";
        System.out.println(java.util.Arrays
                .toString(seperateOnComma(string)));
    }/*from w w  w.j  a v a  2  s .  com*/

    private static String[] seperateOnComma(String string) {
        string = string.replaceAll("\\s+", "");
        string = string.trim();

        String[] stringArray = string.split(",", -1);
        return stringArray;
    }
}

Related Exercise