list中的数据用string接收
List<String> testList=new ArrayList<>(); testList.add("a"); testList.add("b"); testList.add("c"); StringBuilder sb = new StringBuilder(); boolean flag = false; for (String string : testList) { if (flag) { sb.append(","); } else { flag = true; } sb.append(string); } String test = sb.toString(); System.out.println(test); String num = "a"; if(test.indexOf(num)!=-1) { System.out.println("包含"); }else { System.out.println("不包含"); }