Change this to your question / problem / query
public class Employee implements Comparable<Employee> {
int eid;
String name,designation;
int sal;
Employee(int eid, String name, String designation, int sal) {
this.eid = eid;
this.name = name;
this.designation = designation;
this.sal = sal;
}
@Override
public int compareTo(Employee e) {
return name.compareTo(e.name);
}
@Override
public String toString() {
return "Employee [eid=" + eid + ", name=" + name + ", designation=" + designation + ", sal=" + sal + "]";
}
}
public class EmpDemo {
public static void main(String[] args) {
ArrayList<Employee>a=new ArrayList<Employee>();
a.add(new Employee(111,"ganesh","asst",12000));
a.add(new Employee(101,"rajesh","prof",40000));
a.add(new Employee(100,"Aravind","Assoc",45000));
Collections.sort(a);
for(Employee e:a)
System.out.println(e);
}
}