神奇:java中float,double,int的值比较运算

  float x = 302.01f;  
  System.out.println(x == 302.01); //false
  System.out.println(x == 302.01f); //true
  
  double y = 302.01;
  System.out.println(y == 302.01); //true
  System.out.println(y == 302.01f); //false
  
  float z = 302.00f;
  System.out.println(z == 302); //true
  System.out.println(z == 302f); //true
  
  double j = 302;
  System.out.println(j == 302); //true
  System.out.println(j == 302f); //true

原文地址:https://www.cnblogs.com/personnel/p/4583270.html