English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

given a 2 dimentional array

Object tot[ ][ ] = {{"jake","moly"},
{"sue","james"},
{"larry","moses"}};

when i write tot.length
does this give me number of rows or columns or a sum of both?

2007-03-17 08:42:29 · 3 answers · asked by puzzlite 2 in Computers & Internet Programming & Design

3 answers

I am not very good at rows/columns but the much more correct numerical dimension.

tot.length is gonna refer to 1st dimension only. Which is 3 here.

tot[0].length is going for 2nd dimension, 2 here.

Although Java multi-D array isn't necessary rectangular/regular geometry.

2007-03-17 08:51:53 · answer #1 · answered by Andy T 7 · 0 1

tot.length will give you the number of items in the first dimension. tot[index].length will give you the number of items in the second dimension for that index.

2007-03-17 15:47:37 · answer #2 · answered by Rex M 6 · 0 0

sum of both.

2007-03-17 15:48:54 · answer #3 · answered by sethsdadiam 5 · 0 3

fedest.com, questions and answers