String 包含 前缀包含
包含
语法
public boolean contains(CharSequence chars)
示例
String myStr = "abc";
System.out.println(myStr.contains("a")); //返回True
System.out.println(myStr.contains("b")); //返回True
System.out.println(myStr.contains("d")); //返回False
前缀包含
语法
public boolean startsWith(String prefix)
public boolean startsWith(String prefix, int toffset)
示例
String Str = new String("abcdef");
System.out.println(Str.startsWith("abc") ); //返回True
System.out.println(Str.startsWith("def") ); //返回False
System.out.println(Str.startsWith("def", 3) ); //返回True