1

为什么下面的代码用 getDayOfWeek 打印 true 但用 getYear 打印 false?

    LocalDate date = LocalDate.now();
    ArrayList<Object> dateData = new ArrayList<Object>();
    dateData.add(date.getDayOfWeek());
    dateData.add(date.getDayOfWeek());
    System.out.println( dateData.get(0) == dateData.get(1));  // prints true 

    dateData.clear();
    dateData.add(date.getYear());
    dateData.add(date.getYear());
    System.out.println( dateData.get(0) == dateData.get(1));  // prints false
4

0 回答 0