BigDecimal a = new BigDecimal(10); BigDecimal b = new BigDecimal(2); if(a.compareTo(b) == 0){ System.out.println("a等于b"); } if(a.compareTo(b) == 1){ System.out.println("a大于b"); } if(a.compareTo(b) == -1){ System.out.println("a小于b"); } if(a.compareTo(b) > -1){ System.out.println("a大于等于b"); } if(a.compareTo(b) < 1){ System.out.println("a小于等于b"); } if(a.compareTo(BigDecimal.ZERO) > 0){ System.out.println("a大于0"); }
标签:java,BigDecimal,System,println,compareTo,大小,out From: https://www.cnblogs.com/sunline/p/17086218.html