发布网友 发布时间:2022-04-24 10:08
共1个回答
热心网友 时间:2023-10-09 21:19
package test;
public class TestCont {
/**
* @param args
*/
public static void main(String[] args) {
String str = "aaAAbbBBccCC";
String[] s = {"AA","BB","CC","ABCD"};
new TestCont().containstr(str, s);
}
boolean containstr(String str,String[] s){
boolean flag=false;
for (int i = 0; i < s.length; i++) {
if (str.contains(s[i])) {
flag = true;
System.out.println("字符串"+s[i]+"在"+"指定字符串str中!");
}else {
flag = false;
System.out.println("字符串"+s[i]+"不在"+"指定字符串str中!");
}
}
return flag;
}
}