How to remove element from an array

后端 未结 4 499
时光取名叫无心
时光取名叫无心 2020-12-11 17:32

I have an array for example:

String [][] test = {{\"a\",\"1\"},
                    {\"b\",\"1\"},
                    {\"c\",\"1\"}};

Can

4条回答
  •  星月不相逢
    2020-12-11 18:20

    You could set the entry in the array to null (test[0][1] = null;). However, "removing" the item such that the array will have one element less than before is not doable without recreating the array. If you plan to change data in the data structure regularly an ArrayList (or another Collection class depending on your needs) might be more convenient.

提交回复
热议问题