List<String> list = new ArrayList<String>();
list.add("ab");list.add("bc");list.add("cd");
System.out.println(list.indexOf("ab"));//0
System.out.println(list.indexOf("bc"));//1
System.out.println(list.indexOf("b"));//-1
System.out.println(list.contains("ac"));//false
System.out.println(list.contains("ab"));//true
//数组没有indexOf()方法
可以不用使用for循环了