摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.Collections; /** * @author shusheng * @description 扑克游戏 * @Email shusheng@yiji.com * @date 2018/12/18 17:37 ... 阅读全文
posted @ 2019-01-31 11:28 书丶生 阅读(193) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; /** * @author shusheng * @description 自然排序和比较器... 阅读全文
posted @ 2019-01-31 11:26 书丶生 阅读(643) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date ... 阅读全文
posted @ 2019-01-31 11:25 书丶生 阅读(386) 评论(0) 推荐(0)
摘要: 集合工具类:Collections (1) 是针对集合进行操作的工具类 (2) 面试题:Collection 和 Collections 的区别 A:Collection 是单列集合的顶层接口,有两个子接口 List 和 Set B:Collections 是针对集合进行操作的工具类,可以对集合进行 阅读全文
posted @ 2019-01-31 11:24 书丶生 阅读(186) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; /** * @author shusheng * @description ArrayList嵌套HashMap * @Email shusheng@yij... 阅读全文
posted @ 2019-01-31 11:24 书丶生 阅读(1783) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.HashMap; import java.util.Set; /** * @author shusheng * @description HashMap 嵌套 HashMap * @Email shusheng@yiji.com * @date 2018/12/18 14:... 阅读全文
posted @ 2019-01-31 11:23 书丶生 阅读(842) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; /** * @author shusheng * @description HashMap 嵌套 ArrayList * @Email shusheng@yi... 阅读全文
posted @ 2019-01-31 11:23 书丶生 阅读(405) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.Comparator; import java.util.Set; import java.util.TreeMap; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018... 阅读全文
posted @ 2019-01-31 11:22 书丶生 阅读(229) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.LinkedHashMap; import java.util.Set; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/18 13:40 */ public... 阅读全文
posted @ 2019-01-31 11:21 书丶生 阅读(144) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.Set; import java.util.TreeMap; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/18 13:46 */ public class... 阅读全文
posted @ 2019-01-31 11:21 书丶生 阅读(133) 评论(0) 推荐(0)
摘要: 执行结果: 阅读全文
posted @ 2019-01-31 11:20 书丶生 阅读(2828) 评论(0) 推荐(1)
摘要: 打印结果: 阅读全文
posted @ 2019-01-31 11:18 书丶生 阅读(195) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; /** * @author shusheng * @description 根据键获取值,获取所有的键,获取所有的... 阅读全文
posted @ 2019-01-31 11:18 书丶生 阅读(5633) 评论(0) 推荐(0)
摘要: 方式 1:根据键找值 获取所有键的集合 遍历键的集合,获取到每一个键 根据键找值 方式 2:根据键值对对象找键和值获取所有键值对对象的集合 遍历键值对对象的集合,获取到每一个键值对对象 根据键值对对象找键和值 Map 集合遍历的两种方式图解: 阅读全文
posted @ 2019-01-31 11:17 书丶生 阅读(276) 评论(0) 推荐(0)
摘要: Map (1)将键映射到值的对象。一个映射不能包含重复的键;每个键最多只能映射到一个值。 (2)Map 和 Collection 的区别? A:Map 存储的是键值对形式的元素,键唯一,值可以重复。夫妻对 B:Collection 存储的是单独出现的元素,子接口 Set 元素唯一,子接口 List 阅读全文
posted @ 2019-01-31 10:48 书丶生 阅读(211) 评论(0) 推荐(0)
摘要: Map(双列集合) A:Map 集合的数据结构仅仅针对键有效,与值无关。 B:存储的是键值对形式的元素,键唯一,值可重复。 HashMap 底层数据结构是哈希表。线程不安全,效率高 哈希表依赖两个方法:hashCode()和 equals() 执行顺序: 首先判断 hashCode()值是否相同 是 阅读全文
posted @ 2019-01-31 10:46 书丶生 阅读(255) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.Comparator; import java.util.TreeSet; /** * @author shusheng * @description 优化:匿名内部类 * @Email shusheng@yiji.com * @date 2018/12/17 10:36 ... 阅读全文
posted @ 2019-01-31 10:46 书丶生 阅读(377) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.Comparator; import java.util.Scanner; import java.util.TreeSet; /** * @author shusheng * @description 键盘录入5个学生信息,按照总分从高到低输出到控制台 * @Email s... 阅读全文
posted @ 2019-01-31 10:45 书丶生 阅读(959) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.Comparator; import java.util.TreeSet; /** * @author shusheng * @description 比较器排序 * @Email shusheng@yiji.com * @date 2018/12/17 10:36 */... 阅读全文
posted @ 2019-01-31 10:44 书丶生 阅读(427) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.TreeSet; /** * @author shusheng * @description 请按照姓名的长度排序 * @Email shusheng@yiji.com * @date 2018/12/17 10:36 */ public class TreeSetDem... 阅读全文
posted @ 2019-01-31 10:44 书丶生 阅读(409) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.HashSet; import java.util.Random; /** * @author shusheng * @description 获取10个1至20的随机数,要求随机数不能重复 * @Email shusheng@yiji.com * @date 2018/1... 阅读全文
posted @ 2019-01-31 10:42 书丶生 阅读(754) 评论(0) 推荐(0)
摘要: 执行结果: 阅读全文
posted @ 2019-01-31 10:41 书丶生 阅读(95) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.HashSet; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/14 15:04 */ public class DogDemo { /** ... 阅读全文
posted @ 2019-01-31 10:40 书丶生 阅读(650) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.HashSet; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/14 14:11 */ public class HashSetDemo { /**... 阅读全文
posted @ 2019-01-31 10:39 书丶生 阅读(513) 评论(0) 推荐(0)
摘要: HashSet 类概述 不保证 set 的迭代顺序 特别是它不保证该顺序恒久不变。 HashSet 如何保证元素唯一性 底层数据结构是哈希表(元素是链表的数组) 哈希表依赖于哈希值存储添加功能底层依赖两个方法: int hashCode() boolean equals(Object obj) Ha 阅读全文
posted @ 2019-01-31 10:38 书丶生 阅读(133) 评论(0) 推荐(0)
摘要: TreeSet 类概述 使用元素的自然顺序对元素进行排序 或者根据创建 set 时提供的 Comparator 进行排序 具体取决于使用的构造方法。 TreeSet 是如何保证元素的排序和唯一性的 底层数据结构是红黑树(红黑树是一种自平衡的二叉树) TreeSet 真正的比较是依赖于元素的 comp 阅读全文
posted @ 2019-01-31 10:38 书丶生 阅读(329) 评论(0) 推荐(0)
摘要: package com.companyname.common.test; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; /** * @Description 键盘录入多个数据,以0结束,并在控制台输出最大值 * @Author Created by shusheng * @E... 阅读全文
posted @ 2019-01-31 10:34 书丶生 阅读(961) 评论(0) 推荐(0)
摘要: package com.companyname.common.test; import java.util.ArrayList; import java.util.Random; /** * @Description 获取 10 个 1-20 之间的随机数,要求不能重复 * @Author Created by shusheng. * @Email shusheng@yiji.com ... 阅读全文
posted @ 2019-01-31 10:33 书丶生 阅读(747) 评论(0) 推荐(1)
摘要: package com.yjf.esupplier.common.test; import com.yjf.common.util.ToString; import java.util.ArrayList; /** * @author shusheng * @description 集合的嵌套遍历 * @Email shusheng@yiji.com * @date 2018/1... 阅读全文
posted @ 2019-01-31 10:31 书丶生 阅读(607) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.Iterator; /** * @author shusheng * @description 去除集合中字符串的重复值(字符串的内容相同) * @Email shusheng@yiji.com * @date 201... 阅读全文
posted @ 2019-01-31 10:30 书丶生 阅读(131) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date ... 阅读全文
posted @ 2019-01-31 10:30 书丶生 阅读(171) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.Iterator; /** * @author shusheng * @description 去除集合中字符串的重复值(字符串的内容相同) * @Email shusheng@yiji.com * @date 201... 阅读全文
posted @ 2019-01-31 10:29 书丶生 阅读(228) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.Enumeration; import java.util.Vector; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/12 15:48 */ publi... 阅读全文
posted @ 2019-01-31 10:28 书丶生 阅读(153) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.List; import java.util.ListIterator; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date... 阅读全文
posted @ 2019-01-31 10:27 书丶生 阅读(1887) 评论(1) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.ListIterator; /** * @author shusheng * @description * @Email... 阅读全文
posted @ 2019-01-31 10:26 书丶生 阅读(208) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; /** * @author shusheng * @description * @Email shusheng@yiji.com * @da... 阅读全文
posted @ 2019-01-31 10:25 书丶生 阅读(107) 评论(0) 推荐(0)
摘要: package com.yjf.esupplier.common.test; import java.util.LinkedList; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/12 15:24 */ public class LinkedListDemo { ... 阅读全文
posted @ 2019-01-31 10:23 书丶生 阅读(129) 评论(0) 推荐(0)
摘要: 执行结果: 阅读全文
posted @ 2019-01-31 10:22 书丶生 阅读(241) 评论(0) 推荐(0)
摘要: 执行结果: 阅读全文
posted @ 2019-01-31 10:18 书丶生 阅读(157) 评论(0) 推荐(0)
摘要: 执行结果: 阅读全文
posted @ 2019-01-31 10:17 书丶生 阅读(155) 评论(0) 推荐(0)
摘要: 集合类概述: 为什么出现集合类? 面向对象语言对事物的体现都是以对象的形式,所以为了方便对多个对象的操作,Java 就提供了集合类。 集合类的特点 集合只用于存储对象,集合长度是可变的,集合可以存储不同类型的对象。 数据结构:数据的存储方式。 多个集合类是有共性的内容的,我们把这些集合类的共性内容不 阅读全文
posted @ 2019-01-31 10:15 书丶生 阅读(255) 评论(0) 推荐(0)
摘要: 是否是键值对象形式: 是:Map 键是否需要排序: 是:TreeMap 否:HashMap 不知道,就使用 HashMap。 否:Collection 元素是否唯一: 是:Set 元素是否需要排序: 是 :TreeSet 否:HashSet 不知道,就使用 HashSet 否:List 要安全吗: 阅读全文
posted @ 2019-01-31 10:14 书丶生 阅读(142) 评论(0) 推荐(0)
摘要: ArrayXxx:底层数据结构是数组,查询快,增删慢 LinkedXxx:底层数据结构是链表,查询慢,增删快 HashXxx:底层数据结构是哈希表。依赖两个方法:hashCode()和 equals() TreeXxx:底层数据结构是二叉树。两种方式排序:自然排序和比较器排序 阅读全文
posted @ 2019-01-31 10:13 书丶生 阅读(875) 评论(0) 推荐(0)
摘要: 集合:Collection(单列集合) List(有序,可重复) ArrayList 底层数据结构是数组,查询快,增删慢线程不安全,效率高 Vector 底层数据结构是数组,查询快,增删慢线程安全,效率低 LinkedList 底层数据结构是数组链表,查询慢,增删快线程不安全,效率高 Set(无序, 阅读全文
posted @ 2019-01-31 10:10 书丶生 阅读(175) 评论(0) 推荐(0)
摘要: package test; import java.io.*; /** * @author shusheng * @description 序列化与反序列化流 * @Email shusheng@yiji.com * @date 2018/12/23 16:49 */ public class ObjectStreamDemo { //当有些变量不需要序列化时使用 tran... 阅读全文
posted @ 2019-01-31 10:02 书丶生 阅读(167) 评论(0) 推荐(0)
摘要: package test; import java.io.*; import java.util.Enumeration; import java.util.Vector; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/23 15:55 */ public class... 阅读全文
posted @ 2019-01-31 10:01 书丶生 阅读(1562) 评论(0) 推荐(0)
摘要: package test; import java.io.*; /** * @author shusheng * @description 复制两个文件中的内容到一个文件中 * @Email shusheng@yiji.com * @date 2018/12/23 15:43 */ public class SequenceInputStreamDemo { /** ... 阅读全文
posted @ 2019-01-31 10:00 书丶生 阅读(459) 评论(0) 推荐(0)
摘要: package test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; /** * @author shusheng * @description 内存操作流(处理临时信息) * @Email shusheng@yiji.co... 阅读全文
posted @ 2019-01-31 09:59 书丶生 阅读(161) 评论(0) 推荐(0)
摘要: package test; import java.io.*; /** * @author shusheng * @description 操作基本数据类型的流 * @Email shusheng@yiji.com * @date 2018/12/23 0:08 */ public class DataStreamDemo { public static void main... 阅读全文
posted @ 2019-01-31 09:58 书丶生 阅读(194) 评论(0) 推荐(0)