Collection与Collections
来源:互联网 发布:汇率软件 编辑:程序博客网 时间:2024/05/22 05:06
package com.itheima.testinterfacess;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class AddingGroups {
public static void main(String[] args) { Integer [] moreInts = {6,7,8,9,10}; /** public static <T> List<T> asList(T... a) { return new ArrayList<>(a); } */ List<Integer> asList = Arrays.asList(moreInts); //ArrayList()有一个含参构造方法:public ArrayList(Collection<? extends E> c)里面含有Collection的实现类就可以了 Collection<Integer> collection = new ArrayList<Integer>(Arrays.asList(1,2,3,4,5)); //把整个集合添加进来 collection.addAll(asList); for (Integer integer : collection) { System.out.print(integer); } System.out.println("------------------------------------------"); Collections.addAll(collection, 11,12,13,14,15); for (Integer integer : collection) { System.out.print(integer); } System.out.println("------------------------------------------"); Collections.addAll(collection, moreInts); for (Integer integer : collection) { System.out.print(integer); }}
}
输出结果:
12345678910——————————————
123456789101112131415——————————————
123456789101112131415678910
0 0
- collection与collections
- collections与collection
- Collection与Collections
- Java Collections与Collection
- Collection 与Collections
- Collection与Collections
- Collection与Collections
- Java Collection与Collections
- Collection 与 Collections 的区别
- Collection 与 Collections 的区别?
- Collection与Collections的区别
- Collection与Collections的区别
- Collection与Collections的区别
- Collection与Collections的区别
- Collection与Collections的区别
- Collection与Collections的区别
- Collection与Collections的区别
- Java Collection与Collections详解
- cocoa各种图片格式转换
- PTA--双向链表模拟Deque
- AlertDialog最基本应用
- 远行
- android ScrollByScrollTo以及平移动画以及重新LayoutParams的区别
- Collection与Collections
- 【框架-MFC】获取当前鼠标的ICON图标(光标)
- Spring task quartz 定时任务的几种实现
- HDU5882——Balanced Game(2016年青岛区域赛网络赛)
- Fast特征点检测
- Android MVP 简析
- 微分
- js验证时间正则表达式
- hbase伪分布式搭建