副标题#e#
ArrayList 读快 改 慢(底层数组实现)
LinkedList 改快 读 慢 (链表 实现)
Hash两者之间

反复是指equals沟通就是反复
当工具看成索引的时候(键、值):重写equals要领,必需重写hashCode要领,担保equals了,要担保 hashCode也沟通
Set: 没有顺序,不行以反复
List: 有顺序,可以反复
Map:一个叫键,一个值 两个两个往内里放的

Collection要领 举例子一:
package com.Collection;
import java.util.ArrayList;
import java.util.Collection;
public class CollectionTest {
public static void main (String []args){
Collection c = new ArrayList();
c.add("hello");
c.add(new Integer(12));
c.add("lsb");
System.out.println(c.size ());
System.out.println(c);
}
}
显示功效:
#p#副标题#e#
3
[hello, 12, lsb]阐明:打印 c 的时候挪用c.toString()要领,显示的是c中的所有的内容并用[]扩住

Collection要领 举例二: Iterator
package com.Collection;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
public class CollectionTest {
public static void main(String []args){
Collection c = new HashSet();
c.add("hello");
c.add("abc");
c.add("lsb");
Iterator iter = c.iterator();
while(iter.hasNext()){
String str = (String) iter.next();
System.out.println(str);
}
}
}
显示功效:
hello
lsb
abc
Collection要领 举例二: Set要领
package com.Collection;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
public class CollectionTest {
public static void main(String []args){
Collection c1 = new HashSet();
c1.add("a");
c1.add("b");
c1.add("c");
Collection c2 = new HashSet();
c2.add("a");
c2.add ("b");
c2.add("d");
Collection cn = new HashSet(c1);
cn.retainAll(c2);
//取两个荟萃的交集
Collection cm = new HashSet(c1);
cm.addAll(c2);
System.out.println(cn);
System.out.println(cm);//取两个荟萃的并 集
}
}
显示功效:
[a, b] [d, a, c, b]

当工具要较量巨细的时候,那要看该工具是否实现了Comparable接口,该接口中只有一个
要领public int compareTo(Object obj);(假如为jdk1.5以上那么参数为T 泛型),这样才可以较量大 小与排序

MAP

