课堂作业-5

public static void main(String[] args) {

String[] str = {"中文","计算机","ABC","123","[email protected]"};

    //Arrags.asList(str) ;将数组转换成列表

    List List = Arrays.asList(str);

    System.out.println(List);

    // 把数组转换成arraglist new ArragList<>(Arrags.asList(str))

    LinkedList LList =new LinkedList<>(Arrays.asList(str));

    LList.add("haha");

    System.out.println(LList);

    LList.remove("ABC");

    System.out.println(LList);

    //把数组转换成Linkedlist new Linkedlist<>(Arrags.asList(str))

    LinkedList llist =new LinkedList<>(Arrays.asList(str));

    llist.add("haha");

    System.out.println(llist);

    llist.remove("ABC");

    System.out.println(llist);

    // 将列表转换成数组toArrag()

    Object[] temp = LList.toArray();

    for (Object o: temp){

System.out.println(o+"\t");

    }

}

你可能感兴趣的:(课堂作业-5)