Mack Grill

Greenhorn

Posts: 29

posted 5 years ago

I'm trying to determine java expression evaluates the number of columns

Given array T below,

double[][] T = new double[3][5];

what Java expression evaluates the number of columns , and what would this expression return for T?

I'm trying to determine java expression evaluates the number of columns

Given array T below,

double[][] T = new double[3][5];

what Java expression evaluates the number of columns , and what would this expression return for T?

posted 5 years ago

Java doesn't really have two dimensional arrays. Rather, it has arrays of arrays. What that means is, if we assume you mean the first index is the 'number of rows' then the number of 'columns' (the second length of the inner array) can vary from row to row. A common approach to get 'the number of columns' would be to get the length of the array at T[0] (the length of the first array indexed in T).

What does it give you when you run it?

Mack Grill wrote:

...and what would this expression return for T?

What does it give you when you run it?

Steve