I\'m curious why this simple program could be compiled by java using IntelliJ (Java 7).
public class Main {
public static void main(String[] args)
{
It's just the unary plus. If you compile int e = + + 10
you will get the following bytecode:
bipush 10
istore_1
which is exactly equivalent to int e = 10
It is the unary plus, twice. It is not a prefix increment because there is a space. Java does consider whitespace under many circumstances.
The unary plus basically does nothing, it just promotes the operand.
For example, this doesn't compile, because the unary plus causes the byte
to be promoted to int
:
byte b = 0;
b = +b; // doesn't compile