码迷,mamicode.com
首页 > 编程语言 > 详细

java简单的接口程序

时间:2015-06-01 18:53:37      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:

import java.util.Arrays;

public class Grapeh {
	public static void main(String[] args) {
     	Employee[] staff=new Employee[3];
     	staff[0]=new Employee("heln",5003);
     	staff[1]=new Employee("mell",1000);
     	staff[2]=new Employee("kell",500);
     	Arrays.sort(staff);
     	for(Employee e:staff)
     		System.out.println("name="+e.getName()+",salary="+e.getSalary());
	}
}

public class Employee implements Comparable<Employee>{
	private String name;
	private double salary;
	public Employee(String n ,double s){
		name=n;
		salary=s;
	}
	public String getName(){
		return name;
	}
	public double getSalary(){
		return salary;
	}
	public void raiseSalary(double byPercent){
		double raise=salary*byPercent/100;
		salary+=raise;
	}
	public int compareTo(Employee other){
		return Double.compare(salary, other.salary);
	}
	
}

java简单的接口程序

标签:

原文地址:http://blog.csdn.net/u012878380/article/details/46313341

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!