11.如何把一段逗号分隔的字符串转换为一个数组

split

public class DouHaoShuZuFenGe {
    public static void main(String[] args) {
        String orgStr = "a,b,c,d,e,f,g";
        String[] result = orgStr.split(",");

        for (int i = 0; i < result.length; i++) {
            System.out.print(result[i] + "\t");
        }

        for (String s : result) {
            System.out.print(s);
        }
    }
}
posted @ 2020-01-07 19:40  兰茶茶  阅读(238)  评论(0编辑  收藏  举报