集合day01

集合

1.概述:

Collection层次结构中的根接口。Collection 表示一组对象,这些对象也称为  collection 的元素。
一些 collection 允许有重复的元素,而另一些则不允许。
一些 collection 是有序的,而另一些则是无序的。

2. 特点:

   a. 可以自动地调整自己的大小
   b. 只能存储引用数据类型

3. API:

增:
    boolean add(E e)
    boolean addAll(Collection c)
删:
    void clear()
    boolean remove(Object o)
    boolean removeAll(Collection c)
    boolean retainAll(Collection c)
查:
    boolean contains(Object o)
    boolean containsAll(Collection c)
获取集合的属性:
    boolean isEmpty()
    int size()
遍历:
    Object[] toArray()

4.自动拆箱 自动装箱
自动装箱和自动拆箱(JDK5)

  • 自动装箱:基本数据类型转换成对应的引用数据类型 基本数据类型—> 引用数据类型
  • 自动拆箱:引用数据类型转换成对应的基本数据类型 引用数据类型—> 基本数据类型
*  基本数据类型             引用数据类型
 *    byte                  Byte
 *    short                 Short
 *    int                   Integer
 *    long                  Long
 *    float                 Float
 *    double                Double
 *    char                  Character
 *    boolean               Boolean
 public class CollectionDemo2 {
    public static void main(String[] args) {

        int intvalue = 10 ;
        Integer integer = intvalue ;//装
        int i = integer ; //拆
    }
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值