Java Reference
In-Depth Information
public boolean contentEquals(StringBuffer stringBufferObject)
Returns true if and only if this String represents the same sequence of characters as the
StringBuffer argument.
Throws:
NullPointerException if stringBufferObject is null .
public boolean equals(String otherString)
Returns true if the calling object string and the otherString are equal. Otherwise
returns false .
EXAMPLE
After program executes String greeting = "Hello";
greeting.equals("Hello") returns true
greeting.equals("Good-Bye") returns false
greeting.equals("hello") returns false
Note that case matters: "Hello" and "hello" are not equal because one starts with an
uppercase letter and the other starts with a lowercase letter.
public boolean equalsIgnoreCase(String otherString)
Returns true if the calling object string and the otherString are equal, considering upper- and
lowercase versions of a letter to be the same. Otherwise returns false.
EXAMPLE
After program executes String name = "mary";
name.equalsIgnoreCase("Mary") returns true .
public int indexOf(String aString)
Returns the index (position) of the fi rst occurrence of the string aString in the calling object
string. Positions are counted 0, 1, 2, etc. Returns −1 if aString is not found.
EXAMPLE
After program executes String greeting = "Hi Mary!";
greeting.indexOf("Mary") returns 3, and
greeting.indexOf("Sally") returns −1 .
Throws:
NullPointerException if aString is null .
Search WWH ::




Custom Search