Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One plus plus two compiles unexpectedly [duplicate]

Tags:

java

operators

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); 

But this does:

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..

like image 690
djeikyb Avatar asked Dec 23 '14 17:12

djeikyb


People also ask

Are there any problems with the OnePlus 2?

The OnePlus 2 gives you a lot of phone for the money. Unfortunately, there have a few reports of OnePlus 2 problems posted in a number of forums by fans of the phone. We’ve gathered together some of the most common issues — from random reboots to unresponsive buttons — and found possible workarounds and solutions for each one. Check them out below.

Why is my OnePlus 2 overheating?

If you find that your OnePlus 2 is overheating, then you’re not alone. If the phone is downloading updates or apps, or you’re using it to play games for extended periods, then you can expect it to get warm. However, if it’s getting hot for no apparent reason — even when you aren’t using it — then there could be an issue.

How can I make the home button on the OnePlus 2 work better?

If you press the home button with the OnePlus 2 lying on a surface, like a table, it should work better. It should also work more often if you use it one-handed. But, for most people, when their other hand is touching the frame, it seems to become unresponsive. You could put a case on it.

How to fix OnePlus One screen tinting issue?

Try using a different wall socket to see whether the problem persists, or plug your phone into the USB of your computer to see if this helps. Various OnePlus One users have discovered an issue with a yellow tint appearing towards the bottom of their screen like a gradient.


Video Answer


1 Answers

Java is interpreting the working 1 + + 2 as 1 plus positive 2. See the Unary operator section.

like image 60
ryanyuyu Avatar answered Sep 21 '22 00:09

ryanyuyu