Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例: 2D 空配列:[]
[]
ここは使えmatrix[0].lengthますか?
matrix[0].length
これにより、IndexOutofBoundException が発生するようです。誰かが私に理由を説明できますか?
2D 配列は次のように測定できます。
int a[][]; int d1 = a.length; int d2 = d1 > 0 ? a[0].length: 0;
ifは使用できないことに注意してください。a[0]a.length == 0
a[0]
a.length == 0
Java では各配列要素は任意の長さにできるため、a[0].length == n必ずしもというわけではないことに注意してください。a[1].length == n
a[0].length == n
a[1].length == n