Java 重构lamda表达式以使用Comparator.comparingDouble
我有一个如下的lamda表达式。我的IDE(IntellijIDEA)告诉我应该用Java 重构lamda表达式以使用Comparator.comparingDouble,java,intellij-idea,lambda,Java,Intellij Idea,Lambda,我有一个如下的lamda表达式。我的IDE(IntellijIDEA)告诉我应该用比较器来代替它。comparingDouble但是我找不到一种方法来实现它 List<javafx.stage.Screen> screenList = screens; screenList.sort((screenA, screenB) -> Double.compare( screenA.getBounds().getMinX(), screenB.getBo
比较器来代替它。comparingDouble
但是我找不到一种方法来实现它
List<javafx.stage.Screen> screenList = screens;
screenList.sort((screenA, screenB) -> Double.compare(
screenA.getBounds().getMinX(), screenB.getBounds().getMinX()));
或者这是intellij的错误注释?提前感谢您的帮助 您只需要一个将
屏幕
转换为双精度
的函数:
screenList.sort(Comparator.comparingDouble(screen -> screen.getBounds().getMinX()));
您只需要一个将
Screen
转换为double
的函数:
screenList.sort(Comparator.comparingDouble(screen -> screen.getBounds().getMinX()));
在Intellij IDEA中,您只需在比较处调用quick fix(按Alt+Enter),然后在建议处单击Enter替换为Comparator。比较两次,IDEA将自动进行替换
screenList.sort((screenA, screenB) -> Double.com<ALTENTER_HERE>pare(
screenA.getBounds().getMinX(), screenB.getBounds().getMinX()));
在Intellij IDEA中,您只需在比较处调用quick fix(按Alt+Enter),然后在建议处单击Enter替换为Comparator。比较两次,IDEA将自动进行替换
screenList.sort((screenA, screenB) -> Double.com<ALTENTER_HERE>pare(
screenA.getBounds().getMinX(), screenB.getBounds().getMinX()));
非常感谢!:)非常感谢!:)