import java.util.ArrayList; import java.util.LinkedList; public class main { public static void main(String[] args) { LinkedList list1 = new LinkedList<String>(); list1.add("l1_value1"); list1.add("l1_value2"); LinkedList list2 = new LinkedList(); list2.add("l2_value1"); list2.add("l2_value2"); LinkedList list3 = new LinkedList(); list3.add("l3_value1"); list3.add("l3_value2"); ArrayList<LinkedList> arrayList = new ArrayList<LinkedList>(); arrayList.add(list1); arrayList.add(list2); arrayList.add(list1); arrayList.forEach(System.out::println); System.out.println("Classname: " + arrayList.get(0).getClass()); } }
标签:java,LinkedList,arrayList,list1,list2,链表,add,数组 From: https://www.cnblogs.com/xinger123/p/16709572.html