是否有可能摆脱ArrayList
第一个索引号的第一个号码?ArrayList/LinkedList获取第一个索引号
下面是一个例子:
在有5个项目:
path = {0.5,5.0},{0.6,6.0},{0.7,7.0},{0.8,8.0},{0.9,9.0}
而且我想要得到的数5.0
出{0.5,5.0}
...
我path.get(0)
但试了一下只让我回到{0.5,5.0}
。
是否有可能得到5.0
没有得到所有其他数字?
是否有可能摆脱ArrayList
第一个索引号的第一个号码?ArrayList/LinkedList获取第一个索引号
下面是一个例子:
在有5个项目:
path = {0.5,5.0},{0.6,6.0},{0.7,7.0},{0.8,8.0},{0.9,9.0}
而且我想要得到的数5.0
出{0.5,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's
myList.get(0).get(1) // Same logic as above applied to the Collection
集合没有get(int)。 –
Thx为快速回答:)它工作ty ^^ – genaray
@JakubKaszycki一个ArrayList被称为一个集合,因此它扩展AbstractCollection –
你必须从列表中获取数组对象从中得到第二个([1])元素。 –