Why does java require a double equals sign (==) when comparing Integers in a if statement?

For example

if(x = 3.141)
     System.out.println("x is equal to pi.");

is incorrect, it should be

if(x == 3.141)
     System.out.println("x is equal to pi.");

I know that "==" is used to compare integers and "=" is used to set an integer value, but why in a if statement does this remain true?

Is it even allowed to assign a variable a value in an if statement (or initiate a new variable)?

Is there any reason anyone would ever want to assign a variable a new value inside an if statement (if so please provide an example)?

This seems like a question that should already have an answer, but I was unable to find one on here or using google, if this is a duplicate question please tell me and I will remove it immediately.

Edit
Report