Comparator with double type

前端 未结 10 1590
盖世英雄少女心
盖世英雄少女心 2020-11-28 11:50

I have written the following code:

public class NewClass2 implements Comparator
{
    public int compare(Point p1, Point p2)
    {
        retur         


        
10条回答
  •  天命终不由人
    2020-11-28 12:04

    int compare(Double first, Double second) {
        if (Math.abs(first - second) < 1E-6) {
            return 0;
        } else {
            return Double.compare(first, second);
        }
    }
    

提交回复
热议问题