⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e351. operating on lists.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
See also e349 Creating a List. 
    // Create the lists
    List list1 = new ArrayList();
    List list2 = new ArrayList();
    
    // Add elements to the lists ...
    
    // Copy all the elements from list2 to list1 (list1 += list2)
    // list1 becomes the union of list1 and list2
    list1.addAll(list2);
    
    // Remove all the elements in list1 from list2 (list1 -= list2)
    // list1 becomes the asymmetric difference of list1 and list2
    list1.removeAll(list2);
    
    // Get the intersection of list1 and list2
    // list1 becomes the intersection of list1 and list2
    list1.retainAll(list2);
    
    // Remove all elements from a list
    list1.clear();
    
    // Truncate the list
    int newSize = 2;
    list1.subList(newSize, list1.size()).clear();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -