diff --git a/Doc/Sd1/statements.xml b/Doc/Sd1/statements.xml index 07379d47065ce4eb61e5d99f41e5b619e8247438..4d451b5b729fe9ef61ea20a3eacc0db26af94089 100644 --- a/Doc/Sd1/statements.xml +++ b/Doc/Sd1/statements.xml @@ -529,13 +529,6 @@ Found: <emphasis role="red">int</emphasis></screen> <para>In math <quote>=</quote> denotes the equality of objects <abbrev>e.g.</abbrev> values, sets, functions and so on.</para> - - <para>More formally the expression <code - language="java">count = 4</code> is of type <code - language="java">int</code> evaluating to 4 (surprise!). - However an <code language="java">if (...)</code> operates - on <code language="java">boolean</code> values only. We - thus must not supply expressions of any other type.</para> </glossdef> </glossentry> @@ -559,15 +552,19 @@ Found: <emphasis role="red">int</emphasis></screen> </itemizedlist> <para>In particular an expression like <code - language="java">count == 4</code> is of type boolean: - Either <code language="java">true</code> or <code + language="java">count == 4</code> is of type boolean being + either <code language="java">true</code> or <code language="java">false</code>.</para> </glossdef> </glossentry> </glosslist> - <para>Thus <code language="java">count = 4</code> is an - expression evaluating to 4. So the code in question may be + <para>More formally the expression <code language="java">count = + 4</code> is of type <code language="java">int</code> evaluating + to 4 (surprise!). However an <code language="java">if + (...)</code> operates on <code language="java">boolean</code> + values only and <code language="java">if (4)</code> thus does + not make sense at all. The code in question may therefore be re-written as:</para> <programlisting language="java">int count = 1; @@ -579,7 +576,7 @@ if (countAssignment) { <emphasis role="red">// Error: An int is not a boolean!</ }</programlisting> <para>Since the assignment operator is being evaluated from - right to left we do not need braces:</para> + right to left we actually do not need braces:</para> <programlisting language="java">... int countAssignment = count = 4; // Assigning expression count = 4 to variable countAssignment @@ -596,7 +593,8 @@ int countAssignment = count = 4; // Assigning expression count = 4 to variable c final boolean test = (count == 4); // Now using "==" (comparison) in favour of "=" (assignment) System.out.println("test=" + test);</programlisting> - <para>Again we may omit braces here:</para> + <para>Again we may omit braces here due to operator priority + rules:</para> <programlisting language="java">... final boolean test = count == 4; // Now using "==" (comparison) in favour of "=" (assignment)