public class Test3 {
public static void main(String[] args) {
Float aFloat = new Float(0.9F);
Float bFloat = new Float(0.9F);
Double uDouble = new Double(0.9);
System.out.println(aFloat.equals(bFloat));
System.out.println(aFloat == bFloat);
System.out.println(aFloat.equals(uDouble));//精度不一样
System.out.println(bFloat.equals(uDouble));//精度不一样
System.out.println(aFloat==uDouble.floatValue());
System.out.println(aFloat.doubleValue()==uDouble);
}
}
运行结果:
true
false
false
false
true
false