Variables are places where you can store values. They must be declared and assigned a value before use:
String reversed = "";
reversed is the variable assigned to the value "" . Only variables can be on the left side of the task (for example, = ). += - special type of destination. a += b; basically coincides with a = a + b; .
Values ββare the results of expressions. Expressions are things like variable references ( reversed ), constants ( "" ), method calls ( myStr.charAt(0) ), and operations ( a + b ). Values ββcan be on the right side of the task.
I am not sure why it gives you the correct answer, since the code should not run at all when you have a compilation error.
source share