Computer Applications

What is the difference between the following two statements in terms of execution? Explain the results.
x -= 5;
x =- 5;

Java Operators

42 Likes

Answer

The first statement, x -= 5; subtracts 5 from x and assigns the result back to x. It is equivalent to x = x - 5;
The second statement, x =- 5; assigns the value of -5 to x.

Answered By

27 Likes


Related Questions