While compiling the code I get an unexpected error, which never occurred before, it says that I cannot convert from int to an Object...

Code:

maxBundles = max;
    bundleProgressBar.setMaximum(max);
    bundleProgressLabel.setText("Updating Components...");
    // Tell JS that the state is Installing.
    Object[] arr = { 1 };

error:

`103: error: incompatible types
[javac]         Object[] arr = { 1 };`

I know this is a problem with eclipse, because it worked before, so my question is what can I change to resolve it...

有帮助吗?

解决方案

What you're trying to do is called autoboxing - the process of converting a primitive (int in this case) to its Object represantation (Integer in this case), automatically. More on autoboxing and unboxing here.

Autoboxing was introduced in Java 1.5. So check that your project's compiler compliance level is set to 1.5 or above (Project properties -> Java compiler).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top