如何获取数组的子索引值

时间:2023-01-11 21:34:31

We have array like this

我们有这样的数组

[
    [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]
]

When we print array upsublist.get(o); Output come like this [6:02:48 , 06:06:20, 2015-03-24, Tuesday, kuja]

当我们打印数组upsublist.get(o);输出就像这样[6:02:48,06:06:20,2015-03-24,周二,kuja]

We need get only one value like kuja or rahu or guru .Please tell me .How to get Only one value

我们只需要获得一个像kuja或rahu或guru这样的值。请告诉我。如何获得只有一个值

We tried like this upsublist.get(o).get(4) We got like this 如何获取数组的子索引值

我们尝试过这样的upsublist.get(o).get(4)我们就是这样的

1 个解决方案

#1


1  

If [6:02:48 , 06:06:20, 2015-03-24, Tuesday, kuja] is an array and it's length is always 5, you can simply write upsublist.get(o)[4] to get the last element. If it's an ArrayList, you can write upsublist.get(o).get(4).

如果[6:02:48,06:06:20,2015-03-24,星期二,kuja]是一个数组,它的长度总是5,你可以简单地写一下upsublist.get(o)[4]来得到最后一个元素如果是ArrayList,您可以编写upsublist.get(o).get(4)。

If the length is not fixed, you have to find the index of the last element - upsublist.get(o)[upsublist.get(o).length - 1].

如果长度不固定,则必须找到最后一个元素的索引 - upsublist.get(o)[upsublist.get(o).length - 1]。

#1


1  

If [6:02:48 , 06:06:20, 2015-03-24, Tuesday, kuja] is an array and it's length is always 5, you can simply write upsublist.get(o)[4] to get the last element. If it's an ArrayList, you can write upsublist.get(o).get(4).

如果[6:02:48,06:06:20,2015-03-24,星期二,kuja]是一个数组,它的长度总是5,你可以简单地写一下upsublist.get(o)[4]来得到最后一个元素如果是ArrayList,您可以编写upsublist.get(o).get(4)。

If the length is not fixed, you have to find the index of the last element - upsublist.get(o)[upsublist.get(o).length - 1].

如果长度不固定,则必须找到最后一个元素的索引 - upsublist.get(o)[upsublist.get(o).length - 1]。