Idea Code Analysis问题
Idea Code Analysis为什么建议用Java String的contains(Charquens s) 代替indexOf(String s)?是效率高还是因为阅读方便

回答:
应该是便于阅读,String的contains方法源码就是使用的indexOf
    /**     * 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}, false otherwise
     * @since 1.5
     */
    public boolean contains(CharSequence s) {
        return indexOf(s.toString()) > -1;
    }
以上是 Idea Code Analysis问题 的全部内容, 来源链接: utcz.com/p/170985.html








