title: how to make fields of arraylist unique?
body: <pre><code>class Employee implements Comparable&lt;Employee&gt; 
  {
  
      public Employee(int id, String name,int salary ,String designation)
      {..}
  </code></pre>
  
  <p>//getters and setters</p>
  
  <pre><code>}
   public class TestEmployeeSort
  {
       public static void main(String[] args) 
       {
           List&lt;Employee&gt; col = new ArrayList&lt;Employee&gt;();
               Employee one =  new Employee(**2**, "rahul",100, "bc");
           Employee oone =  new Employee(**2**, "sfdful",1300, "bdfsc");
           col.add(one);
           col.add(oone);
  
       }
  }
  </code></pre>
  
  <p>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???</p>