java String
1.indexOf()
/** * Returns the index within this string of the first occurrence of the * specified substring. * * <p>The returned index is the smallest value <i>k</i> for which: * <blockquote><pre> * this.startsWith(str, <i>k</i>) * </pre></blockquote> * If no such value of <i>k</i> exists, then {@code -1} is returned. * * @param str the substring to search for. * @return the index of the first occurrence of the specified substring, * or {@code -1} if there is no such occurrence. */ public int indexOf(String str) { return indexOf(str, 0); }
此函数源码的解释为:参数为要搜索的子字符串,返回值为指定子字符串第一次出现的字符串中的索引。如果不存在该字串则返回-1。

浙公网安备 33010602011771号