怎么判断一个string有没有包含另一个string??

chinapp 2003-10-20 08:10:12
一个最简单的问题,望高手指点
...全文
43 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiachedan 2003-10-20
  • 打赏
  • 举报
回复
同意string1.indexOf(string2)==-1
Bruceyao 2003-10-20
  • 打赏
  • 举报
回复
public int indexOf(String str)
Returns the index within this string of the first occurrence of the specified substring. The integer returned is the smallest value k such that:
this.startsWith(str, k)

is true.

Parameters:
str - any string.
Returns:
if the string argument occurs as a substring within this object, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned.
Throws:
NullPointerException - if str is null.
hq1305018 2003-10-20
  • 打赏
  • 举报
回复
string1.indexOf(string2)==-1
chinapp 2003-10-20
  • 打赏
  • 举报
回复
thx

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧