判断一个字符串是否在另一个字符串中

 /**
     * Returns true if and only if this string contains the specified
     * sequence of char values.
     *
     * @param s the sequence to search for
     * @return true if this string contains <code>s</code>, false otherwise
     * @throws NullPointerException if <code>s</code> is <code>null</code>
     * @since 1.5
     */
    public boolean contains(CharSequence s) {
        return indexOf(s.toString()) > -1;
    }

所以直接使用indexOf(string)>-1

posted @ 2017-05-04 16:47  张主任好  阅读(230)  评论(0编辑  收藏  举报