How can we implement compare method of comparator class [closed]

public int compare(Employee emp1, Employee emp2) {
       if(emp1==null || emp1==null ){
             throw new UnsupportedOperationException("Not an Employee instance");
       }
       if(emp1.getEmpid()<emp2.getEmpid()){        
          return -1;
       }    
       else if(emp1.getEmpid()>emp2.getEmpid()){
           return 1;
       }
       return 0;
    }

Leave a Comment