Adding Multiple Values in ArrayList at a single index

前端 未结 7 458
伪装坚强ぢ
伪装坚强ぢ 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:53

    import java.util.*;
    public class HelloWorld{
    
     public static void main(String []args){
      List threadSafeList = new ArrayList();
        threadSafeList.add("A");
        threadSafeList.add("D");
        threadSafeList.add("F");
    
    Set threadSafeList1 = new TreeSet();
        threadSafeList1.add("B");
        threadSafeList1.add("C");
        threadSafeList1.add("E");
        threadSafeList1.addAll(threadSafeList);
    
    
     List mainList = new ArrayList();   
     mainList.addAll(Arrays.asList(threadSafeList1));
     Iterator mainList1 = mainList.iterator();
     while(mainList1.hasNext()){
     System.out.printf("total : %s %n", mainList1.next());
     }
    }
    }
    

提交回复
热议问题