Why does int = int * double give an error and int *= double does not (in Java)?

Viewed 1998

Why does an assignment of the form int = int * double give an error, and an assignment of the form int *= double does not give an error (in Java)?

Example:

public class TestEmp {

    public static void main(String[] args) {

        double e = 10;
        int r = 1; 
        r *= e;

        r = r * e;
        System.out.println("De uitkomst van r :" + r);

    }
}

r *= e is accepted and r = r * e isn't. Why?

2 Answers
Related