How can I use contains method to search by id only, I want to check if there is id equal 4 or not without using loop, How?
Test Class
public class Test {
private int id;
private String name;
private int age;
public Test(int id, String name, int age) {
this.id = id;
this.name = name;
this.age = age;
}
}
Set Data
List <Test> list = new ArrayList <> ();
list.add(new Test(1, "Name 1", 25));
list.add(new Test(2, "Name 2", 37));
list.add(new Test(3, "Name 3", 63));
list.add(new Test(4, "Name 4", 19));
list.add(new Test(5, "Name 5", 56));