我所说通用,是JDK1.4和JDK1.5的情况下另外,字符串可能很长,可能有科学计数发如1.0E10在JDK1.4的情况下,
可以用BigDecimal的toString方法转换成 10000000000
然后再判断但是在JDK1.5的情况下,该方法变了,转换之后得到的还是1.0E10,有什么方法能通用的判断吗
?
可以用BigDecimal的toString方法转换成 10000000000
然后再判断但是在JDK1.5的情况下,该方法变了,转换之后得到的还是1.0E10,有什么方法能通用的判断吗
?
IntegerTest it = new IntegerTest();
System.out.println(it.test("1.0E10"));
System.out.println(it.test("10000000000"));
System.out.println(it.test("1000000000"));
System.out.println(it.test("1.0E8"));
} public boolean test(String temp) {
BigDecimal db = new BigDecimal(temp);
return db.intValue() == db.doubleValue();
}
}
不知道是不是楼主所说的