contains
public boolean contains(CharSequence s)
Returns true if and only if this string contains the specified sequence of char values.
Parameter:
s - the sequence to search for
Returns:
true if this string contains s, false otherwise
Since:
1.5
indexOf
public int indexOf(int ch)
Returns the index within this string of the first occurrence of the specified character. If a character with value ch occurs in the character sequence represented by this String object, then the index (in Unicode code units) of the first such occurrence is returned. For values of ch in the range from 0 to 0xFFFF (inclusive), this is the smallest value k such that:
this.charAt(k) == ch
is true. For other values of ch, it is the smallest value k such that:
this.codePointAt(k) == ch
is true. In either case, if no such character occurs in this string, then -1 is returned.
Parameters:
ch - a character (Unicode code point).
Returns:
the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.
matches
public boolean matches(String regex)
Tells whether or not this string matches the given regular expression.
An invocation of this method of the form str.matches(regex) yields exactly the same result as the expression
Pattern.matches(regex, str)
Parameters:
regex - the regular expression to which this string is to be matched
Returns:
true if, and only if, this string matches the given regular expression
Throws:
PatternSyntaxException - if the regular expression’s syntax is invalid
Since:
1.4
See Also:
Pattern
백문이 불여일타
1 |
|
참고
Class String https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#method.summary
近期评论