Don't see any problem in your code. You are not getting Found!, because str1 actually does not contain "12,3,14,".
String str1 = "1,3,5,7,9,11,12,14";
String str2 = "12,3,14,";
String str3 = "1,3,5";
if (str1.contains(str2)) { //false
System.out.println("Found!");
}
if (str1.contains(str3)) { //true
System.out.println("Found!");
}
But if you want to find them individually in str1, you may split your str2 and find them one by one.
String str1 = "1,3,5,7,9,11,12,14";
String str2 = "12,3,14,";
String s[] = str2.split(",");
for (String str : s) {
if(str != "" && str1.contains(str))
System.out.println(str+ " found!");
}
split(), split the string and then check if each string in str2's array is present in str1's array