BigDecimal a =new BigDecimal(0.02);BigDecimal b =new BigDecimal(0.01);int num =a.compareTo(b);if( num ==1){ System.out.println("a大于b");}else if( num ==0){ System.out.println("a等于b");}else if( num ==-1){ System.out.println("a小于b");}