在myeclipse6.0編譯完全通過的代碼,在myeclipse10卻編譯報錯。使用的jdk都是自己安裝的jdk6.0(不是eclipse自帶的),編譯級別都是6.0.
代碼如下:
Long a = new Long(0);
a+=new Float("3.2");
在myeclipse10中提示的錯誤如下:
The operator += is undefined for the argument type(s) Long, float
誰知道是什么原因?。恐x謝了。
光陰似箭催人老,日月如移越少年。
+= This operator is defined for basic types. The a and newFloat("3.2") you have here are both objects, so they cannot be calculated. Moreover, the classes under these two Number packages do not provide operation methods. If you want to do +3.2 operation on a, you need to:
Long a = new Long(0); Float f = new Float("3.2"); long result = a.longValue() + f.longValue();