Skip to content

Commit 3ac8b5d

Browse files
authored
Merge pull request #241 from habibasorour/issue_240_listing
Issue 237 fixed: 3.5 listing
2 parents ec32254 + 7e5e090 commit 3ac8b5d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

source/ch3_javadatatypes.ptx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,11 @@ public class Histo {
777777
<title>Arrays</title>
778778

779779
<p>
780-
As was said at the outset of this section, we are going to use Java <c>ArrayLists</c> because they are easier to use and more closely match the way that Python lists behave. However, if you look at Java code on the internet or even in your core Java books you are going to see examples of something called an array. In fact, you have already seen one example of an array declared in the &#x2018;Hello World&#x2019; program. Let's rewrite this program to use primitive arrays rather than array lists.
780+
As was said at the outset of this section, we are going to use Java <c>ArrayLists</c> because they are easier to use and more closely match the way that Python lists behave. However, if you look at Java code on the internet or even in your core Java books you are going to see examples of something called an array. In fact, you have already seen one example of an array declared in the &#x2018;Hello World&#x2019; program. <xref ref="java-array" text="type-global"/> is a rewritten version of <xref ref="java-histogram" text="type-global"/> that uses primitive arrays rather than array lists.
781781
</p>
782782

783-
784-
<program xml:id="java-array" interactive="activecode" language="java" datafile="test.dat">
783+
<listing xml:id="java-array">
784+
<program interactive="activecode" language="java" datafile="test.dat">
785785
<code>
786786
import java.util.Scanner;
787787
import java.io.File;
@@ -812,9 +812,10 @@ public class HistoArray {
812812
}
813813
</code> <tests> </tests>
814814
</program>
815+
</listing>
815816

816817
<p>
817-
The main difference between this example and the previous example is that we declare <c>count</c> to be an <c>Array</c> of integers. We also can initialize short arrays directly using the syntax shown here: <c>Integer[] count = {0,0,0,0,0,0,0,0,0,0}</c>Then notice that we can use the square bracket notation <c>count[idx]</c> to index into an array.
818+
The main difference between <xref ref="java-array" text="type-global"/> and <xref ref="java-histogram" text="type-global"/> is that we declare <c>count</c> to be an <c>Array</c> of integers. We also can initialize short arrays directly using the syntax shown here: <c>Integer[] count = {0,0,0,0,0,0,0,0,0,0}</c>Then notice that we can use the square bracket notation <c>count[idx]</c> to index into an array.
818819
</p>
819820
</section>
820821

0 commit comments

Comments
 (0)