Q:

Why int i1 = -+0007 is same as int i2 = +-0007 ? And why both plus-minus compile fine?

What rules govern such unexpected behaviour?
int i1 = -+0007;
int i2 = +-0007;
System.out.println(i1);  // output: -7
System.out.println(i2);  // output: -7

    int i3 = +-+0007;   // -7
    int i4 = -+-0007;   // 7

I understand that unary sign operator is right-associative. But if minus goes first (rightmost), it seems that next plus (to the left) does not change sign from minus to plus (i.e. does nothing!). But second minus changes sign (from negative to positive).
Besides we cannot use ++ or -- anywhere in this sequence of +-+-+- (+--+ is compile error: rightmost + (or leftmost +) is wrong operand of -- operation).

A:

Unary - changes the sign. Unary + doesn't, it's mostly pointless, it does an unary numeric promotion, you can see here for some more details about it.
So in your first line:
int i1 = -+0007;

+ does nothing - changes to -7
Second line:
int i2 = +-0007;

- changes to -7 + does nothing
+--+ is a compile error because -- is a different operator that can only operate on a variable. Something like the following will work:
int b = 1;
int a = -++b; // increment b by 1, change the sign and assign to a
System.out.println(a); // prints -2

You can use parenthesis or add space to make +--+ compile
int i = +-(-+7); // will be equal to 7 because only the 2 `-` change the sign
int i = +- -+7;

