[英]How to find the index of an arraylist in an arraylist?
I have an ArrayList of ArrayLists of T, and I am trying to find the index of the ArrayList that contains a certain object 我有一个T的ArrayList的ArrayList,并且我试图找到包含某个对象的ArrayList的索引
private int indexOfItem(T item)
{
int index = 10000;
for(int i = 0; i < bigList.size(); i++)
{
if(bigList.get(i).contains(item))
{
index = i;
}
}
return index;
}
this works but is there a better way to do this using the indexOf() method that arrayLists have? 这可行,但是有没有更好的方法使用arrayLists拥有的indexOf()方法呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.