From ccd1878e64297aea8430574e1baccca68a292cce Mon Sep 17 00:00:00 2001 From: "nshizirungudieumerci@gmail.com" Date: Fri, 7 Aug 2026 16:17:38 -0400 Subject: [PATCH] added a parsons problem for section 3.5 --- source/ch3_javadatatypes.ptx | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/source/ch3_javadatatypes.ptx b/source/ch3_javadatatypes.ptx index df08c4a..f348eb0 100644 --- a/source/ch3_javadatatypes.ptx +++ b/source/ch3_javadatatypes.ptx @@ -967,6 +967,48 @@ public class HistoArray {

The main difference between and is that we declare count to be an Array of integers. We also can initialize short arrays directly using the syntax shown here: Integer[] count = {0,0,0,0,0,0,0,0,0,0}Then notice that we can use the square bracket notation count[idx] to index into an array.

+ + + +

+ Construct a short Java program that creates an array of three integers, + changes the first value, and prints it. Drag the blocks into the correct order on the right. +

+
+ + + public class ArrayExample { + public static void main(String[] args) { + + + + + Integer[] nums = {1, 2, 3}; + + + Integer[] nums = (1, 2, 3); + + + + + + nums[0] = 5; + + + nums(0) = 5; + + + + + System.out.println(nums[0]); + + + + } + } + + +