C# 集合的交集 差集 并集 去重 两个对象list,直接比较是不行的,因为他们存的地址不一样 需要重写GetHashCode()与Equals(object obj)方法告诉电脑 class Student { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } } class CompareStudent : IEqualityComparer<Student>…
Date Date类不常用,很多方法被废弃了,常用它的两个构造方法来new一个Date对象. Date d1 = new Date(); //不传任何参数,代表当前时间点 System.out.println(d1); //输出 Sat Jul 13 09:51:50 CST 2019 //在Java中以1970年1月1日 00:00:00为时间原点,由于时区问题,祖国时间是8:00:00 Date d2 = new Date(4000); //传入一个long型数值,表示在时间原点之后 Sys…
实现思路很简单,直接上代码: package test; import java.util.HashSet; import java.util.Set; public class Test { public static void main(String[] args) { Set<Integer> result = new HashSet<Integer>(); Set<Integer> set1 = new HashSet<Integer>(){{ ad…