Question: This is allowed by the Java compiler, what is it doing?

```
int x = x = 1;

```

I realize that x is assigned to x, but how can it have two `=`s?

Answer: 
Read assignment statement from right to left:

Acording to [Assignment Operators](https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.26)

> 
> There are 12 assignment operators; all are syntactically
>  right-associative (they group right-to-left). Thus, a=b=c means
>  a=(b=c), which assigns the value of c to b and then assigns the value
>  of b to a.
> 
> 
> 

So, 

```
int x = x = 1; 

```

is the same as 

```
x = (x = 1); 

```

then 

```
x = 1; x = x;

```
`int x` puts `x` on the stack.

The right hand part `x = 1` assigns 1 to `x`. But this is an *expression* with value 1.

Finally this is re-assigned to `x`.