class Employee implements Comparable<Employee>
{
public Employee(int id, String name,int salary ,String designation)
{..}
//getters and setters
}
public class TestEmployeeSort
{
public static void main(String[] args)
{
List<Employee> col = new ArrayList<Employee>();
Employee one = new Employee(**2**, "rahul",100, "bc");
Employee oone = new Employee(**2**, "sfdful",1300, "bdfsc");
col.add(one);
col.add(oone);
}
}
here i made a program where 4 fields in object are passed named id, name, salary and designation now from the arraylist objects i want to pick up one entity of object out of 4 used named "id" and want to make it unique so that no object with duplicate id can be inserted ...(similar to working of set but don't want to use set here) how can it be done .....i tried making a method in constructor and passing "this.id" in a set to check duplicates but still it is not working???