s-day02-集合的继承体系简述
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.inmind.collection01;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/*
|
||||
1.数组是固定不变的保存任意类型数据
|
||||
2.集合是长度可变,但是只能保存引用类型
|
||||
3.arraylist底层是Object[];
|
||||
*/
|
||||
public class Demo01 {
|
||||
public static void main(String[] args) {
|
||||
//创建集合添加内容
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("wo");
|
||||
list.add("ai");
|
||||
list.add("java");
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.inmind.collection01;
|
||||
/*
|
||||
Collection 常用功能
|
||||
Collection是所有单列集合的父接口,因此在Collection中定义了单列集合(List和Set)通用的一些方法,这些方法可用于操作所有的单列集合。方法如下:
|
||||
|
||||
有2个子接口:List和Set
|
||||
|
||||
public boolean add(E e): 把给定的对象添加到当前集合中 。
|
||||
public void clear() :清空集合中所有的元素。
|
||||
public boolean remove(E e): 把给定的对象在当前集合中删除。
|
||||
public boolean contains(E e): 判断当前集合中是否包含给定的对象。
|
||||
public boolean isEmpty(): 判断当前集合是否为空。
|
||||
public int size(): 返回集合中元素的个数。
|
||||
public Object[] toArray(): 把集合中的元素,存储到数组中。
|
||||
*/
|
||||
public class Demo02 {
|
||||
}
|
||||
Reference in New Issue
Block a user