java String包含子串和包含字符

String father="Welcome you to come here";
String child ="you";
1. 用到 String类的  indexOf() 方法  返回值!=-1 则包含 ,返回第一次出现的指定子字符串在此字符串中的索引。 2.使用String.matches方法判断是否包含子串,注意正则表达式元字符的转义 3.StringUtils.contains    判断是否包含某个字符    org.apache.commons.lang.StringUtils  包 4..String类提供的方法  public boolean contains(CharSequence s) 参考: [1]. http://codingstandards.iteye.com/blog/1181490

转载于:https://my.oschina.net/itfanr/blog/195672

猜你喜欢

转载自blog.csdn.net/weixin_34041003/article/details/91799481