原文链接:这里,这里!
contains是判断元素是否在动态数组中。用法如下
@Test
public void test() {
ArrayList arrayList = new ArrayList();
arrayList.add("AAA");
arrayList.add("BBB");
arrayList.add("CCC");
System.out.println(arrayList.contains("AAA"));
System.out.println(arrayList.contains("DDD"));
}
@Test
public void test2(){
JSONArray jsonArray = new JSONArray();
jsonArray.add(1);
jsonArray.add(2);
jsonArray.add(3);
System.out.println(jsonArray.contains(2));
System.out.println(jsonArray.contains(4));
}