本博客中常用类与集合

1.Employee

package stream;

public class Employee implements ComparableEmployee{

	private int id;
	private String name;
	private int age;
	private double salary;

	public double getSalary() {
		return salary;
	}

	public String getName() {
		return name;
	}

	public Employee(int id, String name, int age, double salary) {

		this.id = id;
		this.name = name;
		this.age = age;
		this.salary = salary;
	}

	@Override
	public String toString() {
		return Employee{ + id= + id + , name=' + name + ''' + , age= + age + , salary= + salary + '}';
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null  getClass() != o.getClass())
			return false;

		Employee employee = (Employee) o;

		if (id != employee.id)
			return false;
		if (age != employee.age)
			return false;
		if (Double.compare(employee.salary, salary) != 0)
			return false;
		return name != null  name.equals(employee.name)  employee.name == null;
	}

	@Override
	public int hashCode() {
		int result;
		long temp;
		result = id;
		result = 31  result + (name != null  name.hashCode()  0);
		result = 31  result + age;
		temp = Double.doubleToLongBits(salary);
		result = 31  result + (int) (temp ^ (temp  32));
		return result;
	}

	@Override
	public int compareTo(Employee employee) {
		if (this.id != employee.id)
			return this.id - employee.id;
		else
			return this.age - employee.age;
	}
}

2.EmployeeData

package stream;

import java.util.ArrayList;
import java.util.List;

public class EmployeeData {
	
	public static ListEmployee getEmployees(){
		ListEmployee list = new ArrayList();
		
		list.add(new Employee(1001, 马化腾, 34, 6000.38));
		list.add(new Employee(1002, 马云, 12, 9876.12));
		list.add(new Employee(1003, 刘强东, 33, 3000.82));
		list.add(new Employee(1004, 雷军, 26, 7657.37));
		list.add(new Employee(1005, 李彦宏, 65, 5555.32));
		list.add(new Employee(1006, 比尔盖茨, 42, 9500.43));
		list.add(new Employee(1007, 任正非, 26, 4333.32));
		list.add(new Employee(1008, 扎克伯格, 35, 2500.32));
		list.add(new Employee(1008, 扎克伯格, 35, 2500.32));
		
		return list;
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

运维小菜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值