Adding Multiple Values in ArrayList at a single index

前端 未结 7 453
伪装坚强ぢ
伪装坚强ぢ 2021-01-12 01:35

I have a double ArrayList in java like this.

List values = new ArrayList(2);

Now what I want t

相关标签:
7条回答
  • 2021-01-12 01:58

    create simple method to do that for you:

    public void addMulti(String[] strings,List list){
        for (int i = 0; i < strings.length; i++) {
            list.add(strings[i]);
        }
    }
    

    Then you can create

    String[] wrong ={"1","2","3","4","5","6"};
    

    and add it with this method to your list.

    0 讨论(0)
提交回复
热议问题