/**
* 检查一个字符串中是否含有某个子字符串
* 例如: "ABC_001"里面是否包含"ABC"字符串
* @author
*/
public class Test {
public static void main(String[] args) {
String str="ABC_001";
if(str.indexOf("ABC")==-1){ //str.indexOf("ABC")表示返回ABC在str中第一次出现的位置索引
System.out.println("不包含");
}else{
System.out.println("包含");
}
}
}
* 检查一个字符串中是否含有某个子字符串
* 例如: "ABC_001"里面是否包含"ABC"字符串
* @author
*/
public class Test {
public static void main(String[] args) {
String str="ABC_001";
if(str.indexOf("ABC")==-1){ //str.indexOf("ABC")表示返回ABC在str中第一次出现的位置索引
System.out.println("不包含");
}else{
System.out.println("包含");
}
}
}