随笔分类 -  集合、数组

深入理解Java PriorityQueue
摘要:参考https://www.cnblogs.com/CarpenterLee/p/5488070.html PriorityQueue Java中PriorityQueue通过二叉小顶堆实现,可以用一棵完全二叉树表示。本文从Queue接口函数出发,结合生动的图解,深入浅出地分析PriorityQue 阅读全文

posted @ 2018-06-06 09:53 lijingran 阅读(952) 评论(0) 推荐(0)

java之二叉树--未完待续
摘要:参考http://how2j.cn/k/collection/collection-tree/476.html#nowhere 二叉树概念 二叉树由各种节点组成二叉树特点:每个节点都可以有左子节点,右子节点每一个节点都有一个值 二叉树排序-插入数据 假设通过二叉树对如下10个随机数进行排序67,7, 阅读全文

posted @ 2018-05-27 15:51 lijingran 阅读(187) 评论(0) 推荐(0)

java集合框架之比较器Comparator、Comparable
摘要:参考http://how2j.cn/k/collection/collection-comparator-comparable/693.html Comparator 假设Hero有三个属性 name,hp,damage一个集合中放存放10个Hero,通过Collections.sort对这10个进 阅读全文

posted @ 2018-05-25 14:57 lijingran 阅读(652) 评论(0) 推荐(0)

java集合框架之HashCode
摘要:参考http://how2j.cn/k/collection/collection-hashcode/371.html List查找的低效率 假设在List中存放着无重复名称,没有顺序的2000000个Hero要把名字叫做“hero 1000000”的对象找出来List的做法是对每一个进行挨个遍历, 阅读全文

posted @ 2018-05-25 10:52 lijingran 阅读(375) 评论(0) 推荐(0)

java集合框架之几种set(HashSet LinkedHashSet TreeSet )
摘要:参考http://how2j.cn/k/collection/collection-sets/691.html#nowhere HashSet LinkedHashSet TreeSet HashSet: 无序LinkedHashSet: 按照插入顺序TreeSet: 从小到大排序 利用Linked 阅读全文

posted @ 2018-05-24 11:50 lijingran 阅读(182) 评论(0) 推荐(0)

java集合框架之HashMap和Hashtable的区别
摘要:参考http://how2j.cn/k/collection/collection-hashmap-vs-hashtable/692.html#nowhere HashMap和Hashtable的区别 HashMap和Hashtable都实现了Map接口,都是键值对保存数据的方式区别1: HashM 阅读全文

posted @ 2018-05-24 11:37 lijingran 阅读(148) 评论(0) 推荐(0)

java集合框架之Collections
摘要:参考http://how2j.cn/k/collection/collection-collections/369.html Collections是一个类,容器的工具类,就如同Arrays是数组的工具类 反转 reverse 使List中的数据发生翻转 混淆 shuffle 混淆List中数据的顺 阅读全文

posted @ 2018-05-24 10:53 lijingran 阅读(335) 评论(0) 推荐(0)

java集合框架之Collection
摘要:参考http://how2j.cn/k/collection/collection-collection/366.html Collection是 Set List Queue和 Deque的接口Queue: 先进先出队列Deque: 双向链表注:Collection和Map之间没有关系,Colle 阅读全文

posted @ 2018-05-24 10:40 lijingran 阅读(132) 评论(0) 推荐(0)

java集合框架之HashSet
摘要:参考http://how2j.cn/k/collection/collection-hashset/364.html#nowhere 元素不能重复 Set中的元素,不能重复重复判断标准是: 首先看hashcode是否相同 如果hashcode不同,则认为是不同数据 如果hashcode相同,再比较e 阅读全文

posted @ 2018-05-24 10:37 lijingran 阅读(235) 评论(0) 推荐(0)

java集合框架之HashMap
摘要:参考http://how2j.cn/k/collection/collection-hashmap/365.html#nowhere HashMap的键值对 HashMap储存数据的方式是—— 键值对 键不能重复,值可以重复 对于HashMap而言,key是唯一的,不可以重复的。 所以,以相同的ke 阅读全文

posted @ 2018-05-23 23:12 lijingran 阅读(345) 评论(0) 推荐(0)

java集合框架之ArrayList与LinkedList的区别
摘要:参考http://how2j.cn/k/collection/collection-arraylist-vs-linkedlist/690.html#nowhere ArrayList和LinkedList的区别 ArrayList 插入,删除数据慢LinkedList, 插入,删除数据快Array 阅读全文

posted @ 2018-05-23 22:03 lijingran 阅读(320) 评论(0) 推荐(0)

java集合框架之LinkedList
摘要:参考http://how2j.cn/k/collection/collection-linkedlist/370.html LinkedList 与 List接口 与ArrayList一样,LinkedList也实现了List接口,诸如add,remove,contains等等方法。 详细使用,请参 阅读全文

posted @ 2018-05-23 15:00 lijingran 阅读(228) 评论(0) 推荐(0)

java集合框架之ArrayList
摘要:参考http://how2j.cn/k/collection/collection-arraylist/363.html 使用数组的局限性 一个长度是10的数据:Hero[] heroArr=new Hero[10]; 如果用数组存放数据,那么超过10的数据就放不下了 如果数据不足10个,那么数组空 阅读全文

posted @ 2018-05-23 14:57 lijingran 阅读(939) 评论(0) 推荐(0)

HashMap和LinkedHashMap的区别
摘要:参考:https://blog.csdn.net/a822631129/article/details/78520111 java为数据结构中的映射定义了一个接口java.util.Map;它有四个实现类,分别是HashMap Hashtable LinkedHashMap 和TreeMap. Ma 阅读全文

posted @ 2018-05-22 17:21 lijingran 阅读(21560) 评论(0) 推荐(0)

HashMap遍历和使用
摘要:转自https://blog.csdn.net/zhangfengBX/article/details/76783348 map的几种遍历方式: HashMap和Hashtable的联系和区别 实现原理相同,功能相同,底层都是哈希表结构,查询速度快,在很多情况下可以互用,早期的版本一般都是安全的。 阅读全文

posted @ 2018-05-10 22:08 lijingran 阅读(4124) 评论(0) 推荐(0)

Arrays.asList()
摘要:Arrays.asList() 将一个数组转化为一个List对象,这个方法会返回一个ArrayList类型的对象。 @SafeVarargs @SuppressWarnings("varargs") public static <T> List<T> asList(T... a) { return 阅读全文

posted @ 2018-04-18 09:27 lijingran 阅读(1493) 评论(0) 推荐(0)

HashMap浅入理解
摘要:HashMap不能保证元素的顺序,HashMap能够将键设为null,也可以将值设为null,与之对应的是Hashtable,(注意大小写:不是HashTable),Hashtable不能将键和值设为null,否则运行时会报空指针异常错误; HashMap线程不安全,Hashtable线程安全 Ha 阅读全文

posted @ 2018-04-13 19:17 lijingran 阅读(160) 评论(0) 推荐(0)

java Queue中 add/offer,element/peek,remove/poll区别
摘要:转自https://blog.csdn.net/u012050154/article/details/60572567 java Queue中 add/offer,element/peek,remove/poll中的三个方法均为重复的方法,在选择使用时不免有所疑惑,这里简单区别一下: 1、add() 阅读全文

posted @ 2018-04-10 12:16 lijingran 阅读(924) 评论(0) 推荐(0)

Java之Collections.emptyList()、emptySet()、emptyMap()的作用和好处以及要注意的地方
摘要:转自https://www.cnblogs.com/qiumingcheng/p/7126281.html 先说明一下好处有哪些:1,如果你想 new 一个空的 List ,而这个 List 以后也不会再添加元素,那么就用 Collections.emptyList() 好了。new ArrayLi 阅读全文

posted @ 2018-04-05 20:13 lijingran 阅读(576) 评论(0) 推荐(0)

java ArrayList
摘要:结果是: 1、0 2、1 阅读全文

posted @ 2018-03-23 11:00 lijingran 阅读(179) 评论(0) 推荐(0)

导航