First Commit for Sorting Examples.

This commit is contained in:
maverick
2016-07-28 16:40:34 +05:30
parent 1e862df8d4
commit bf1c98fd16
8 changed files with 480 additions and 0 deletions
@@ -0,0 +1,49 @@
package com.baeldung.beans;
public class Employee implements Comparable{
private String name;
private int age;
private double salary;
public Employee() {
}
public Employee(String name, int age, double salary) {
super();
this.name = name;
this.age = age;
this.salary = salary;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
@Override
public String toString() {
return "("+name+","+age+","+salary+")";
}
@Override
public int compareTo(Object o) {
Employee e = (Employee) o;
return getAge() - e.getAge() ;
}
}