Skip to content

Instantly share code, notes, and snippets.

@anirudhjoshi
Created November 5, 2012 05:23
Show Gist options
  • Save anirudhjoshi/4015495 to your computer and use it in GitHub Desktop.
Save anirudhjoshi/4015495 to your computer and use it in GitHub Desktop.
Employee.java
public class Employee implements Comparable {
private String id;
private String name;
public Employee(String id, String name){
setId(id);
setName(name);
}
public String getId(){
return id;
}
public String getName(){
return name;
}
public void setId(String id){
this.id = id;
}
public void setName(String name){
this.name = name;
}
@Override
public String toString(){
return "ID: " + id + " NAME: " + name;
}
@Override
public int compareTo(Object o){
Employee c = (Employee) o;
Integer a = Integer.parseInt(id);
Integer b = Integer.parseInt(c.id);
return a.compareTo(b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment