Add String to beginning of String array

前端 未结 9 962
孤独总比滥情好
孤独总比滥情好 2021-01-01 09:44

Is it possible to add a string to beginning of String array without iterating the entire array.

9条回答
  •  一生所求
    2021-01-01 10:18

    try

        String[] a = {"1", "2"};
        String[] a2 = new String[a.length + 1];
        a2[0] = "0";
        System.arraycopy(a, 0, a2, 1, a.length);
    

提交回复
热议问题