Autoboxing isnt working properly [duplicate]

2019-07-31 18:40发布

问题:

This question already has an answer here:

  • What is “compiler compliance level” in Eclipse? 4 answers

I am trying to implement autoboxing but it's showing an error:

Cannot convert from int to integer.

package JavaTraining;
public class Wrap { 
    public static void main(String ar[])
    {
        Integer a=100;
        String i=a.toString();
        System.out.println(i);
        System.out.println(a);
    }
}

Eclispe version is 3.1

回答1:

(This is relevant to Eclipse specifically) -
You need to change your Compiler compliance level to at least 1.5.

Project -> Properties -> Java Compiler -> Compiler compliance level