摘要: 本文主要讲述Lsit集合的排序方式: 1 /** 2 * 集合的排序方式:2种方式 3 */ 4 public class GenericWork { 5 public static void main(String[] args) { 6 ArrayList<Employee> employeeA 阅读全文
posted @ 2023-01-03 22:01 zwGitOne 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 本文主要讲述HashSet的一道作业题,给出示例代码,讲出输出的内容。 一. 示例代码如下: 1 public class HomeWork06 { 2 public static void main(String[] args) { 3 HashSet hashSet = new HashSet( 阅读全文
posted @ 2023-01-03 18:56 zwGitOne 阅读(35) 评论(0) 推荐(0) 编辑
摘要: HashSet的去重 添加的对象需要重写hashCode()和equals()方法,其中hashCode()方法,应该是根据自定义类对象的成员属性值计算得来,equals()方法,应该是比较自定义类对象的成员属性值是否相同【不是地址】。 TreeSet的去重 添加的对象类需要实现Comparable 阅读全文
posted @ 2023-01-03 15:49 zwGitOne 阅读(101) 评论(0) 推荐(0) 编辑
摘要: TreeSet的add()方法解析【添加和去重】 1 public class HomeWork05 { 2 public static void main(String[] args) { 3 // TreeSet最好是同一类型。 4 // TreeSet treeSet = new TreeSe 阅读全文
posted @ 2023-01-03 15:35 zwGitOne 阅读(71) 评论(0) 推荐(0) 编辑