都要先引入依赖:import java.lang.String
1、contains:返回值为Boolean
String str = "abcdefg";
boolean check = str.contains("cde");
if(check){
//包含指定字符串
}else{
//不包含指定字符串
}
2、indexOf:返回值为int
String str = "abcdefg";
int check = str.indexOf("cde");
if(check != -1){
//包含指定字符串
}else{
//不包含指定字符串
}