What is the Java notation for height in a 2D array?

AI Thread Summary
In Java, to determine the "height" of a 2D array, you use the notation math[0].length, which returns the number of columns. For an array defined as math[][] with dimensions 12x15, math.length gives the number of rows (12), while math[0].length provides the number of columns (15). This distinction is important as the first dimension represents rows and the second represents columns. Thus, accessing the second dimension's length is the correct method to retrieve the height of the array. Understanding this notation is essential for effectively working with 2D arrays in Java.
UrbanXrisis
Messages
1,192
Reaction score
1
I know that in an array called math[][], the "math.length" will give me the length, or "width" of the array. What is the notation for the "height"?

Ex, if math[][] was a 12x15 array, then math.length=12. how would I get the # 15?
 
Physics news on Phys.org
I'm not sure there is a method for that. Since you know that you have 12 one-dimensional arrays of length 15, I think you could store one of those arrays in another 1D array and then apply myArray.length to get the 15.
 


The notation for the "height" in a 2D array in Java is simply the length of the second dimension. In your example, the "height" would be accessed by using math[0].length, which would return the value 15. This is because the first dimension represents the rows and the second dimension represents the columns in a 2D array. Therefore, to get the "height" of the array, you would need to access the length of the second dimension.
 
I multiplied the values first without the error limit. Got 19.38. rounded it off to 2 significant figures since the given data has 2 significant figures. So = 19. For error I used the above formula. It comes out about 1.48. Now my question is. Should I write the answer as 19±1.5 (rounding 1.48 to 2 significant figures) OR should I write it as 19±1. So in short, should the error have same number of significant figures as the mean value or should it have the same number of decimal places as...
Thread 'A cylinder connected to a hanging mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...
Back
Top