因为要修改一个以前的老项目,老项目用的jdk是1.4版本,遂在项目右键Properties-Java Compiler中将Compiler compliance level 设成了1.4.
以为万事大吉了呢,昨晚上因为Integer的一个方法发现了问题
Integer中有个方法valueOf
static Integer | valueOf(int i) 返回一个表示指定的 int 值的 Integer 实例。 |
static Integer | valueOf(String s) 返回保持指定的 String 的值的 Integer 对象。 |
static Integer | valueOf(String s, int radix) 返回一个 Integer 对象,该对象中保持了用第二个参数提供的基数进行分析时从指定的 String 中提取的值。 |
其中valueOf(int i)
从以下版本开始: 1.5
也就是在1.5之前没有这个方法,但是在eclipse中却有这个方法的提示
找了半天,原来问题出在这,在Java Build Path 中Libraries 中jdk是1.5的,把它remove掉,添加一个1.4的就OK了
window->preference->JAVA->Installed JRES->jre1.5.0_12
window->preference->MyEclipse->Application Servers->Tomcat->JDK