how to get list index in java with custom Model

I have a Model Class something like this:

public class Model {
String title, tag;

public Model() {
}

public Model(String title, String tag) {
    this.title = title;
    this.tag = tag;
}

public String getTitle() {
    return title;
}

public void setTitle(String title) {
    this.title = title;
}

public String getTag() {
    return tag;
}

public void setTag(String tag) {
    this.tag = tag;
}

}

So I have ArrayList<Model> arr; according to my Model class so, I want to get the Index of the tag for example –

//Let Suppose I have ArrayList Like this.

arr.add(new Model("SKYFALL","Action"));
arr.add(new Model("CASINO ROYALE","Thriller"));

//and so on.........

For example, I want the index of which have a Action tag.

I did something like this – int index = arr.indexOf("Action");

but its index is always -1

Answer

You are finding the index wrong, your array list is of the array of object(Model class) while you find the index using a string.

You need to provide the object to find the index

    Model actionModel = new Model("SKYFALL","Action")
    arr.add(actionModel);
    arr.add(new Model("CASINO ROYALE","Thriller"));

To find index

int index = arr.indexOf(actionModel);

Edit:
You can run a loop on the array list to find the index of an item

for (int i = 0; i < arr.size; i++) {
        if (arr.get(i).getTag().eqauls("Action")){
                index = i;
                break;
         }
    }