Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>i++</code> is an assignment to a variable <code>i</code>.</p> <p>In your case, <code>zero++</code> is an equivalent to <code>zero = zero + 1</code>. So <code>0++</code> would mean <code>0 = 0 + 1</code>, which makes no sense, as well as <code>getInt() = getInt() + 1</code>.</p> <p>More accurately :</p> <pre><code>int oneA = zero++; </code></pre> <p>means</p> <pre><code>int oneA = zero; zero = zero + 1; // OK, oneA == 0, zero == 1 </code></pre> <hr> <pre><code>int oneB = 0++; </code></pre> <p>means</p> <pre><code>int oneB = 0; 0 = 0 + 1; // wrong, can't assign value to a value. </code></pre> <hr> <pre><code>int oneC = getInt()++; </code></pre> <p>means</p> <pre><code>int oneC = getInt(); getInt() = getInt() + 1; // wrong, can't assign value to a method return value. </code></pre> <hr> <p>From a more general point of view, a variable is a <strong>L-value</strong>, meaning that it refers to a memory location, and can therefore be assigned. <strong>L</strong> in <strong>L</strong>-value stands for <strong>left</strong> side of the assignment operator (i.e. <code>=</code>), even if L-values can be found either on the left side or the right side of the assignment operator (<code>x = y</code> for instance).</p> <p>The opposite is <strong>R-value</strong> (<strong>R</strong> stands for <strong>right</strong> side of the assignment operator). R-values can be used only on the right side of assignment statements, to assign something to a L-value. Typically, R-values are literals (numbers, characters strings...) and methods.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload