展开全部
如果是完全匹配的查找可以这样
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList arrayList = new ArrayList();
arrayList.add("1");
arrayList.add("2");
arrayList.add("3");
arrayList.add("4");
arrayList.add("5");
arrayList.add("1");
arrayList.add("2");
boolean blnFound = arrayList.contains("2");
System.out.println("Does arrayList contain 2 ? " + blnFound);
int index = arrayList.indexOf("4");
if(index == -1)
System.out.println("ArrayList does not contain 4");
else
System.out.println("ArrayList contains 4 at index :" + index);
int lastIndex = arrayList.lastIndexOf("1");
if(lastIndex == -1)
System.out.println("ArrayList does not contain 1");
else
System.out.println("Last occurrence of 1 in ArrayList is at index :");
}
如果不能完全匹配,比如以指定字母开头,可以遍历62616964757a686964616fe78988e69d8331333431373837ArrayList元素每个元素进行匹配