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);
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/xnuuuu/p/12163388.html
今日推荐