亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從員工名單中打印特定月份入職的員工名單?

如何從員工名單中打印特定月份入職的員工名單?

慕姐8265434 2023-09-20 19:12:30
如何從員工名單中打印特定月份入職的員工名單?您好,我正在嘗試打印假設“六月”加入的員工名單?下面是我的代碼,Pojo 類:-import java.time.LocalDate;public class Employee {    private String name;    private String empID;    private Designation designation;    private LocalDate dateOfJoining;    private int monthlySalary;    public Employee(String name, String empID, Designation designation, LocalDate dateOfJoining, int monthlySalary) {        super();        this.name = name;        this.empID = empID;        this.designation = designation;        this.dateOfJoining = dateOfJoining;        this.monthlySalary = monthlySalary;    }    public Employee() {    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public String getEmpID() {        return empID;    }    public void setEmpID(String empID) {        this.empID = empID;    }    public Designation getDesignation() {        return designation;    }    public void setDesignation(Designation designation) {        this.designation = designation;    }    public LocalDate getDOJ() {        return dateOfJoining;    }    public void setDOJ(LocalDate dOJ) {        dateOfJoining = dOJ;    }    public int getMonthlySalary() {        return monthlySalary;    }    public void setMonthlySalary(int monthlySalary) {        this.monthlySalary = monthlySalary;    }    @Override    public int hashCode() {        final int prime = 31;        int result = 1;        result = prime * result + ((dateOfJoining == null) ? 0 : dateOfJoining.hashCode());        result = prime * result + ((designation == null) ? 0 : designation.hashCode());        result = prime * result + ((empID == null) ? 0 : empID.hashCode());        result = prime * result + monthlySalary;        result = prime * result + ((name == null) ? 0 : name.hashCode());        return result;    }我為加入詳細信息的日期創建了一個單獨的類。
查看完整描述

3 回答

?
元芳怎么了

TA貢獻1798條經驗 獲得超7個贊

如果您只想打印 6 月份加入的員工姓名:

listofemployee.stream().filter(employee->employee.getDOJ().getMonth().equals(Month.JUNE)).map(employee.getName()).forEach(System.out::println);


查看完整回答
反對 回復 2023-09-20
?
慕尼黑5688855

TA貢獻1848條經驗 獲得超2個贊

   for (Employee employee : listofemployee) {

        LocalDate key = employee.getDOJ();

        String value = employee.getName();

        if (key.getMonthValue() == 06) {

            hashmap.put(key, value);

        }

    }

    System.out.println(hashmap);

但這在重復的情況下不起作用


查看完整回答
反對 回復 2023-09-20
?
HUWWW

TA貢獻1874條經驗 獲得超12個贊

    for(Employee employee: listofemployee) 

    {

        LocalDate key = employee.getDOJ();

        String value = employee.getName();

        if(key.getMonth() == 6 )

         {

            hashMap.put(key, value); //if the date of joining is same day and time it would replace, as map dont share dups.

          }


     }


查看完整回答
反對 回復 2023-09-20
  • 3 回答
  • 0 關注
  • 156 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號