Java8之Lambda表达式概念篇:https://www.jianshu.com/p/67ebee04b2b3
Java8之Stream类:https://www.jianshu.com/p/c53eb31752c4
1.新建list Test和User实体类
import java.util.Calendar;
import java.util.Objects;
import lombok.Data;
@Data
public class User {
String userName;
String passWord;
@Override
public boolean equals(Object obj) {
/*if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
User other = (User) obj;
if (passWord == null) {
if (other.passWord != null)
return false;
} else if (!passWord.equals(other.passWord))
return false;
if (userName == null) {
if (other.userName != null)
return false;
} else if (!userName.equals(other.userName))
return false;
return true;*/
if (obj == this) return true;
if (!(obj instanceof User)) {
return false;
}
User user = (User) obj;
return
Objects.equals(userName, user.userName) &&
Objects.equals(passWord, user.passWord);
}
@Override
public int hashCode() {
/* final int prime = 31;
int result = 1;
result = prime * result + ((passWord == null) ? 0 : passWord.hashCode());
result = prime * result + ((userName == null) ? 0 : userName.hashCode());
return result;*/
return Objects.hash(passWord, userName);
}
public User(String userName, String passWord) {
super();
this.userName = userName;
this.passWord = passWord;
}
public String getUserName() {
return userName;
}
public User() {
super();