我们有这样的数组
[
[6:02:48 , 06:06:20, 2015-03-24, Tuesday, kuja],
[06:06:20, 06:15:25, 2015-03-24, Tuesday, rahu],
[06:15:25, 06:23:30, 2015-03-24, Tuesday, guru],
[06:23:30, 06:33:05, 2015-03-24, Tuesday, shani],
[06:33:05, 06:41:40, 2015-03-24, Tuesday, budha],
[06:41:40, 06:45:12, 2015-03-24, Tuesday, kethu],
[06:45:12, 06:55:18, 2015-03-24, Tuesday, shukra]
]
当我们打印数组upsublist.get(o);
输出像这样
[6:02:48 , 06:06:20, 2015-03-24, Tuesday, kuja]
我们只需要获取一个值,例如
kuja or rahu or guru
。请告诉我。如何获取仅一个值我们像这样尝试
upsublist.get(o).get(4)
我们像这样
最佳答案
如果[6:02:48 , 06:06:20, 2015-03-24, Tuesday, kuja]
是一个数组,并且其长度始终为5,则只需编写upsublist.get(o)[4]
即可获取最后一个元素。如果它是ArrayList,则可以编写upsublist.get(o).get(4)
。
如果长度不固定,则必须找到最后一个元素的索引-upsublist.get(o)[upsublist.get(o).length - 1]
。
关于java - 如何获取数组的子索引值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29229777/