Two dimensional arrays

× "Is a" and "Has a" relation "Has a" relation Arrays as in memory Two Dimensional Arrays Exception Handling Variable, Object & Reference Multi-threading Website Design / Development Story of JEE modules
× JAVA, JEE, SQL: Online Private Tutoring Project based Training Concept based Training Basic Java:           $180 Advanced Java:     $300
(Threads,Sockets,JDBC,GUI)
Advanced Java:     $300
(with games projects like
PcMan, PingPong, TicTacToe)
Author: Bharat Chhajer

Overview

Java Arrays allow you to store a number of values of the same type. Two dimensional array is created as an array of arrays. Lets say we want to store low and high temperatures of 4 days, Monday through Thrusday. We would create an array like

Two dimenstional array described using memory diagram.

We are actually creating two arrays of 4 double variables each. Low temperatures for 4 days would be stored in one and High temperatures for 4 days would be stored in another. The reference/address of this two arrays would be stored where ? For that an array of 2 reference variables is created and its reference is stored in LHTemp. The LHTemp array is used to store the reference of the low and high temperature arrays. So, LHTemp is an array containing references of the two other arrays. Hence LHTemp is an array of arrays.

NEXT: Array as in memory

Author: Bharat Chhajer