解决方案 »

  1.   

    System.out.println(Integer.valueOf("001011"));,
    居然
    Exception in thread "main" java.lang.NumberFormatException: For input string: "001011"
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.valueOf(Unknown Source)
    at sample.Main.main(Main.java:9)
      

  2.   

    复制下来的代码运行结果是:
    true
    1011
    false
    Exception in thread "main" java.lang.NumberFormatException: For input string: "?001011"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    后面的字符串中有个不可见的空白或其它字符。
      

  3.   

    楼主,你也真是的,还千古奇BUGpublic class Main {
    public static void main(String[] args) {
    Provinces province = new Provinces("001011", "广东省");
    System.out.println("001011".equals(province.code));
    System.out.println(Integer.valueOf(province.code)); Provinces province2 = new Provinces("001011", "广东省");
    System.out.println("001011".equals(province2.code));
    System.out.println(Integer.valueOf(province2.code));
    }
    }class Provinces {
    public Provinces(String code, String name) {
    super();
    this.code = code;
    this.name = name;
    } public String code;
    public String name;
    }你试试这个代码
      

  4.   

    结果就是true
    1011
    true
    1011
      

  5.   

    问题已经解决,是ISO-8895-1格式的文本转换成UTF-8文本时,ISO-8895-1文本前面隐藏了一个“?”字符导致的,要先转换成其它格式,删掉“?”再转换回来就可以了