Integer.parseInt() 错误

public class Integer{
    public static void main(String[] args){
        int a=Integer.parseInt("3232");
        System.out.print(a);
    }
}    

对于此代码,编译时出现如下错误:

 对于Integer.toString()也是如此,但是对于Double,Long等类却不会出现这种情况。

如果用MyEclipse编译它,说法是:

The method parseInt(String) is undefined for the type 

也就是说parseInt这个方法并未被定义。

具体原因不清楚,解决方法是把Interger.parseInt()改为java.lang.Integer.parseInt()。

按道理编译器会自动检查程序包java.lang,所以对于要加上这个前缀不明了。

相信自己

原文地址:https://www.cnblogs.com/drl937676516/p/3633200.html