public static void main(String[] args) { String str="ABC_001"; if(str.indexOf("ABC")!=-1){ System.out.println("包含"); }else{ System.out.println("不包含"); } }
本文提供了一个简单的Java示例,展示了如何使用indexOf方法来判断一个字符串是否包含特定的子串。通过对示例代码的分析,读者可以了解到基本的字符串操作方法。
public static void main(String[] args) { String str="ABC_001"; if(str.indexOf("ABC")!=-1){ System.out.println("包含"); }else{ System.out.println("不包含"); } }
转载于:https://www.cnblogs.com/zhujiabin/p/4938818.html

被折叠的 条评论
为什么被折叠?