为何Java的+ =,-=,* =,/ =复合赋值运算符不须要强制转换?

问题:

Until today, I thought that for example: 直到今天,我还觉得例如: ui

i += j;

Was just a shortcut for: 只是如下方面的捷径: this

i = i + j;

But if we try this: 可是,若是咱们尝试这样作: spa

int i = 5;
long j = 8;

Then i = i + j; 那么i = i + j; will not compile but i += j; 不会编译,可是i += j; will compile fine. 会编译的很好。 .net

Does it mean that in fact i += j; 这是否意味着实际上i += j; is a shortcut for something like this i = (type of i) (i + j) ? 是这样的快捷方式i = (type of i) (i + j)吗? code


解决方案:

参考一: https://stackoom.com/question/aY1r/为何Java的-复合赋值运算符不须要强制转换
参考二: https://oldbug.net/q/aY1r/Why-don-t-Java-s-compound-assignment-operators-require-casting
相关文章
相关标签/搜索