一加二意外地编译 [英] One plus plus two compiles unexpectedly
本文介绍了一加二意外地编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我希望它不会编译,并且不会:
So, I expect this not to compile, and it doesn't:
// the two is inc'd, so reduces symbolically to println(int int)
// which is a compile error
System.out.println(1 ++ 2);
但是确实如此:
System.out.println(1 + + 2); // returns three
有什么作用?它也不应该编译吗?
What gives? Shouldn't it also not compile?
此外,由于运算符,很难搜索这个问题.
Also, this question is very hard to search for because of the operators..
推荐答案
Java is interpreting the working 1 + + 2
as 1 plus positive 2. See the Unary operator section.
这篇关于一加二意外地编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文