Just for fun, try this: 
    public static void main(String[] args) {
        double d1 = 0.1 + 0.2;
        double d2 = 0.3;
        System.out.println(Double.compare(d1, d2));
    }