Java tutorial
//package com.java2s; import java.util.ArrayList; public class Main { public static int indexOf(Object o, ArrayList<Object> elementData) { if (o == null) { for (int i = 0; i < elementData.size(); i++) if (elementData.get(i) == null) return i; } else { for (int i = 0; i < elementData.size(); i++) if (o.equals(elementData.get(i))) return i; } return -1; } }