gpt4 book ai didi

java - ArrayList/LinkedList 获取第一个索引号

转载 作者:行者123 更新时间:2023-12-01 21:53:20 24 4
gpt4 key购买 nike

是否可以从ArrayList中获取第一个索引的第一个数字?

这是一个例子:

其中有 5 项:

path = {0.5,5.0},{0.6,6.0},{0.7,7.0},{0.8,8.0},{0.9,9.0}

我想从 {0.5,5.0} 中获取数字 5.0...

我尝试使用 path.get(0) 但它只给我 {0.5,5.0} 返回。

是否有可能在不获得所有其他数字的情况下获得 5.0

最佳答案

如果您的 ArrayList 包含数组,这就是正确的方法

myList.get(0)[1] // You're getting the index 1 from the 1st array of your ArrayList

否则,如果它包含其他ArrayList的

myList.get(0).get(1) // Same logic as above applied to the Collection

关于java - ArrayList/LinkedList 获取第一个索引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34837069/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com