public class equals
{
public static void main(String[] args)
  {
double a=5.36;
double b=5.32;
if(a>b)//出现不能比较的出错提示?
{
System.out.println(a);
}
else
{
System.out.println(b);
}
  }
}怎么不可以呢,不是很正常吗。

解决方案 »

  1.   

    double直接比较时会出现问题,你可以先将它们转换成BigDecimal,然后比较
      

  2.   

    这里主要是因为float和double是为科学计算而设计的,它们并没有提供一个非常精确的值
      

  3.   

    public class pppr
    {
    public static void main(String[] args)
      {
       double a=5.36;
       double b=5.32;
       if(a>b)//出现不能比较的出错提示?
       {
          System.out.println(a);
       }  
       else
       {
          System.out.println(b);
       }
      }
    }
    你的类名不能用关键字呀向这样一来就可以了