Java's String type provides the indexOf method, we can use it to determine whether a string of strings contains another string of strings, indexOf returns the subscript of the string, starting from 0, if there is no such string, return Is -1.
Look at the code:
public class StringTest {
public static void main(String[] args) {
String abc = "abc";
System.out.println(abc.indexOf("a"));//0 存在 下标为0
System.out.println(abc.indexOf("bc"));// 1 存在 下标为1
System.out.println(abc.indexOf("ac"));// -1 不存在
System.out.println(abc.indexOf("d"));//-1 不存在
}
}