Question: ```
Long x;
int y = (int) x;

```

Eclipse is marking this line with the error: 

> 
> Can not cast Long to an int
> 
> 
>

Answer: 
`Long x` is an object. 

```
int y = x.intValue();

```
```
Long x1 = 123L;
long x2 = 123L;

int y1 = Math.toIntExact(x1);
int y2 = Math.toIntExact(x2);

```

**This conversion will work with primitive as well as with non-primitive types as well.**