Reputation: 325
is there a function that take array list item and bring back item index ?
for ex:
int indexItem = ArrayList.getItemIndexByName(itemName);
Upvotes: 0
Views: 20890
Reputation: 26362
I think that you are looking for IndexOf.
int indexItem = myArray.IndexOf(itemName);
You can use it like this.
String itemName = "Hello";
ArrayList myArray = new ArrayList();
myArray.Add( "Hello" );
myArray.Add( "World" );
// Get index of "Hello"
int indexItem = myArray.IndexOf(itemName);
Upvotes: 2
Reputation: 70170
There is no single method that will give you this, but you could first search for your item by name, then use ArrayList.IndexOf.
Upvotes: 1