2014-10-08 77 views
0

最近,我更新的Java 8版本,但我有问题,比较器(版本7中的一切都工作):比较在Java 8

lastplace = Collections.max(place, 
        new Comparator<Place>() { 

       public int compare(Place o1, 
         Place o2) { 
        return (o1.getDateFrom() 
          .compareTo(o2.getDateFrom())); 
       } 
      }); 

现在比较需要继承其他方法(thenComparingInt,thenComparingLong等等),但我不需要它们

如何在几行代码中解决这个问题?

+1

那么问题是什么?你至少试过编译代码吗?我想不是,因为如果你有,你会看到代码编译得很好。 – 2014-10-08 07:07:17

回答

2

在比较类新mehods是默认的,你不需要实现,因为它提供了默认implementation.I认为这个问题是与你的IDE由于设置1.7.Just编译器遵从性级别更改编译器级别设置为1.8,如果没有,则升级IDE。