List ArrayList Map HashMap 区别
1.
List是接口,List特性就是有序,会确保以一定的顺序保存元素.
ArrayList是它的实现类,是一个用数组实现的List.
Map是接口,Map特性就是根据一个对象查找对象.
HashMap是它的实现类,HashMap用hash表实现的Map,就是利用对象的hashcode(hashcode()是Object的方法)进行快速散列查找.
2.
以前这么写List list = new Vector(); Map map = new HashTable();
现在这么写List list = new ArrayList(); Map map = new HashMap();
ArrayList和HashMap是异步的,Vector和HashTable是同步的,
所以ArrayList和HashMap并不是线程安全的 ,而Vector和HashTable是线程安全的,
因为同步需要花费机器时间,所以Vector和HashTable的执行效率要低于ArrayList和HashMap。