当然有更简单的方法:
public static void main(String[] args) {
String str="1,2,4,12,15,01003,23,56";
str=","+str+",";
String test1="1";
String test2="01";
System.out.println(str.indexOf(","+test1+",")>-1);
System.out.println(str.indexOf(","+test2+",")>-1);
}
如图:
我解答不了,但希望有人能帮助你,帮你顶一下