title: How to compare two objects in Java 8
body: <p>Lets take an example you have two employee object having same values as follows.</p>
  
  <pre><code>Employee employee1 = new Employee(1001, "Sam", 20000);
  Employee employee2 = new Employee(1001, "Sam", 20000);
  if(doCompareEmployees(employee1, employee2)){
      System.out.println("Both employee objects are same.");
  }else{
      System.out.println("Both employee objects are not same.");
  }
  
  //Here is compare method using java 8.
  
  private boolean doCompareEmployees(Employee employee1, Employee employee2) {
  int returnValue = Comparator.comparing(Employee::getID)
      .thenComparing(Employee::getName)
      .thenComparing(Employee::getSalary)
      .compare(employee1, employee2);
      if (returnValue != 0){
          return false;
      }   
      return true;
  }
  </code></pre>
  
  <p>I would like know about, is there any other better approach to compare objects in Java 8 ?</p>