Skip Top Navigation Bar
Why Java?
Learner's Corner
Teacher's Corner
Java Playground
Home
Getting Setup
Learn
Practice
Apply
Other Resources
Write Code Segments that Require Two-Dimensional Arrays
Your Turn
Write program code to complete the provided tasks.
Run the code in the Java Playground to see if your code generates the desired result.
Make necessary changes until you have satisfied the tasks.
Introduction to Two-Dimensional Array Tutorial
Practice 1: Temperatures Array
Write a code segment that initializes a 7x24
double
array for storing hourly temperatures over a week and sets all values to 0.0 as a default.
Try the code in the Java Playground to verify your prediction.
Practice 2: Alternating True and False
Create a
boolean[][] board
that is a 5x5 two-dimensional array. The values should alternate between
true
and
false
. Even rows will start with
true
and odd rows will start with
false
.
Try the code in the Java Playground to verify your prediction.