Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ArrayList/LinkedList获取第一个索引号_Java_List_Arraylist_Processing_Indexof - Fatal编程技术网

Java ArrayList/LinkedList获取第一个索引号

Java ArrayList/LinkedList获取第一个索引号,java,list,arraylist,processing,indexof,Java,List,Arraylist,Processing,Indexof,是否可以从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 如果您的大括号中的大括号实际上是(可能是),您可以使用: myArray.get(0)[index]获取所需的索引。在您的示例中,它是

是否可以从
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

如果您的大括号中的大括号实际上是(可能是),您可以使用:

myArray.get(0)[index]
获取所需的索引。在您的示例中,它是:

myArray.get(0)[1];

注意:如果您的
ArrayList
元素也是
ArrayList
,那么您需要使用
get(0)。get(1)
而不是
get(0)[1]

如果您的大括号中的大括号实际上是(可能是),您可以使用:

myArray.get(0)[index]
获取所需的索引。在您的示例中,它是:

myArray.get(0)[1];

注意:如果您的
ArrayList
元素也是
ArrayList
,那么您需要使用
get(0)。get(1)
而不是
get(0)[1]
如果您的
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

如果
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

必须从列表中获取数组对象才能从第二个([1])元素中获取。必须从列表中获取数组对象才能从第二个([1])元素中获取。集合没有get(int)。@JakubKaszycki数组列表称为集合,因此它扩展了AbstractCollection
Collection
没有方法
E get(int)
。这是
列表的方法
,Imeant@JakubKaszycki我从来没有说过收集有一个获取方法。。。但不管怎样。你刚才说“与上面应用于集合的逻辑相同”集合没有get(int)。@JakubKaszycki数组列表称为集合,因此它扩展了AbstractCollection
Collection
没有方法
E get(int)
。这是
列表的方法
,Imeant@JakubKaszycki我从来没有说过收集有一个获取方法。。。但不管怎样。你刚才说“与上述应用于集合的逻辑相同”也有效:)Thx a lot也有效:)Thx a lot