ArrayList 和Vector ,HashTable和HashMap异同

相同点:

1.都实现了List接口(List接口继承自Collection接口)

2.有序集合,数据可重复,可按索引号取值(而HashSet无序,不可重复)

不同点:

1.Vector是线程安全的,而ArrayList是线程不安全的,因此单线程最好使用Arraylist,效率高,多线程使用Vector

2.当增加存储空间时,Vector增长原来的一倍,ArrayList增加原来的0.5倍

HashTable和HashMap

1.HashTable是线程安全的,而HashMap是不安全的

2.HashTable不允许null值(key或者value),而HashMap允许

3.HashTable有contains方法,而HashMap替换为containsKey和containsValue方法

原文地址:https://www.cnblogs.com/phil_jing/p/5179396.html