ArrayList、LinkedList
摘要:区别 ArrayList是实现了基于数组的数据结构,内存连续;LinkedList是基于链表结构。 对于随机访问的get和set方法查询元素,ArrayList要优于LinkedList,因为LinkedList循环链表寻找元素。 对于新增和删除操作add和remove,LinkedList比较高效
阅读全文
posted @
2024-06-08 16:15
zhengbiyu
阅读(10)
推荐(0) 编辑
HashMap
摘要:流程 resize 初始化大小16,负载因子0.75。 当桶节点个数大于扩容阈值,会进行扩容,容量扩大到2倍。 //离100最近的2次幂是128,默认负载因子是0.75,所以扩容阈值是128*0.75=96,以下put发生rehash HashMap hashMap = new HashMap(10
阅读全文
posted @
2023-03-19 18:15
zhengbiyu
阅读(29)
推荐(0) 编辑
list的remove方法
摘要:list有两个remove方法; E remove(int index);//根据索引删除 boolean remove(Object o);//根据对象删除 List<String> list = new ArrayList<String>(); String a = "1"; String b
阅读全文
posted @
2018-06-28 18:10
zhengbiyu
阅读(2899)
推荐(0) 编辑