
import java.util.ArrayList;

public class Contains
{
    public static void main(String[] args)
    {
        ArrayList<String> myList = new ArrayList<>();
        
        myList.add("john");  // Index 0
        myList.add("peter"); // Index 1
        myList.add("mary");  // Index 2
        myList.add("peter"); // Index 3

        System.out.println( myList.lastIndexOf("peter") ); //1
        System.out.println( myList.lastIndexOf("xxxxx") ); //-1
    } 
}
