Commit a1a7509b authored by Dr. Martin Goik's avatar Dr. Martin Goik

Cosmetics

parent 0c9c52a5
......@@ -324,7 +324,7 @@ representation</screen></td>
<para>Discuss this argument by estimating the number of distinct
patterns.</para>
<para>Hint: Consider a keycard's (likely?) grid of possible punch
<para>Hint: Consider a key card's (likely?) grid of possible punch
positions:</para>
<mediaobject>
......@@ -359,8 +359,8 @@ representation</screen></td>
<m:mi>4.294.967.296</m:mi>
</m:mrow>
</m:math>
</inlineequation> distinct possibilities. Thus a lot of keycards
may get lost before a hotel manager needs to start
</inlineequation> distinct possibilities. Thus a lot of key
cards may get lost before a hotel manager needs to start
worrying.</para>
</answer>
</qandaentry>
......@@ -2733,9 +2733,8 @@ int a = 20,
<answer>
<para>Integer literals starting with <quote>0</quote> denote octal
representation. The octal system's set of digits is
{0,1,2,3,4,5,6,7}. Therefore <quote>9</quote> is no valid
digit.</para>
representation. The octal system's set of digits is {0, 1, 2, 3,
4, 5, 6, 7}. Therefore <quote>9</quote> is no valid digit.</para>
</answer>
</qandaentry>
</qandadiv>
......@@ -3363,7 +3362,7 @@ System.out.println('&amp;' + ": " + ((int) '&amp;'));
&lt;body&gt;&lt;h1 style="<emphasis role="bold">color: #FF0000;</emphasis>"&gt;My heading&lt;/h1&gt;&lt;/body&gt;
&lt;/html&gt;</programlisting>
<para>Write a program printing the hexadecimal representation
<para>Write a program printing hexadecimal representations like
<inlineequation>
<m:math display="inline">
<m:msub>
......@@ -3809,7 +3808,7 @@ System.out.println(11 + 22 + " is our result");</programlisting></td>
</tr>
</informaltable>
<para>Explain the different outcomes. </para>
<para>Explain the different outcomes.</para>
<tip>
<para>Read about the <quote>+</quote> operator's role
......@@ -3916,7 +3915,14 @@ System.out.println("Decimal:" + (512 +
</tr>
</informaltable>
<para>Like in this exercises first example the above code is
<para>We inspect the first expression <code>"Decimal:" +
<emphasis role="red">512</emphasis></code>. <xref
linkend="glo_Java"/> implicitly converts the int literal 512
into a String "512". Then the two + operator concatenates both
Strings into <code>"Decimal:<emphasis
role="red">512</emphasis>"</code>. Evaluating the whole
expression from left to right this pattern keeps repeating.
Like in this exercises first example the above code is thus
equivalent to:</para>
<programlisting language="java">...
......@@ -4040,7 +4046,7 @@ System.out.println("Decimal:" + "512" +
</question>
<answer>
<para>There are at least two solutions on offer:</para>
<para>There are at least three solutions on offer:</para>
<glosslist>
<glossentry>
......@@ -4064,6 +4070,24 @@ System.out.println("Decimal:" + "512" +
<programlisting language="java">System.out.println("Some " + '"' + "special" + '"' + " words.");</programlisting>
</glossdef>
</glossentry>
<glossentry>
<glossterm>Using multi line strings</glossterm>
<glossdef>
<para><xref linkend="glo_Java"/> 15 introduces strings
possibly spanning multiple lines being delimited by pairs of
<code>"""</code>. This construct allows for <code>"</code>
and <code>""</code> (but obviously not for <code>"""</code>)
within a given multi line string: </para>
<programlisting language="java">System.out.println(System.out.println("""
Some "special" words.""");</programlisting>
<para>Notice the necessity of a newline after the starting
<code>"""</code>.</para>
</glossdef>
</glossentry>
</glosslist>
</answer>
</qandaentry>
......
......@@ -3446,7 +3446,7 @@ Row group index 3 /_\_\_\_\_\
/_/_/_/_/_/_\
Row group index 4 /_\_\_\_\_\_\ End of tree's body
/_/_/_/_/_/_/_\
<emphasis role="red">[___]</emphasis> <emphasis
<emphasis role="red">[___]</emphasis> <emphasis
role="red">Part 3: Bottom trunk line.</emphasis></programlisting>
<para>For each row group (albeit having different length) the
......@@ -3732,7 +3732,7 @@ System.out.println("<emphasis role="red">[___]</emphasis>");
and <classname
xlink:href="https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/String.html">String</classname>.<methodname
xlink:href="https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/String.html#repeat(int)">repeat()</methodname>.
This variant's full source code is on offer at <link
This variants full source code is on offer at <link
xlink:href="https://gitlab.mi.hdm-stuttgart.de/goik/GoikLectures/tree/master/Doc/Sd1/Ref/Statements/MoreFunXmasTree/src/main/java/de/hdm_stuttgart/mi/sd1/XmasUsingFormat.java">XmasUsingFormat.java</link>.</para>
<programlisting language="java">final int numberOfRowGroups = 5; // You may easily change this parameter.
......@@ -3952,7 +3952,8 @@ System.out.format("%"+ (numberOfRowGroups + 6) + "s\n", "[___]");
<tr>
<td valign="top"><programlisting language="none">
System.out.format("Start:%5d:End", <emphasis role="red">12</emphasis>); // Printing 12 right aligned in a field of 5 characters padded with 3 spaces to the left
System.out.format("Start:<emphasis role="red">%5d</emphasis>:End", <emphasis
role="red">12</emphasis>); // Printing 12 right aligned in a field of 5 characters padded with 3 spaces to the left
<emphasis role="red"> ▲ ┃</emphasis>
<emphasis role="red">┗━━━━━━━━━┛</emphasis>
<emphasis role="red">replace</emphasis>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment