Wednesday 13 March 2013

startsWith(String)


startsWith(String)


Returns: true if the character sequence represented by the argument is a prefix of the substring of this
object starting at index toffset; false otherwise. The result is false if toffset is negative or
greater than the length of this String object; otherwise the result is the same as the result of the
expression
this.subString(toffset).startsWith(prefix)
Throws:
NullPointerException - if prefix is null.
startsWith(String)
Declaration:
public boolean startsWith(java.lang.String prefix)
Description:
Tests if this string starts with the specified prefix.
Parameters:
prefix - the prefix.
Returns: true if the character sequence represented by the argument is a prefix of the character sequence
represented by this string; false otherwise. Note also that true will be returned if the argument is an
empty string or is equal to this String object as determined by the equals(Object) method.
Throws:
NullPointerException - if prefix is null.
Since: JDK1.0
endsWith(String)
Declaration:
public boolean endsWith(java.lang.String suffix)
Description:
Tests if this string ends with the specified suffix.
Parameters:
suffix - the suffix.
Returns: true if the character sequence represented by the argument is a suffix of the character sequence
represented by this object; false otherwise. Note that the result will be true if the argument is the
empty string or is equal to this String object as determined by the equals(Object) method.
Throws:
NullPointerException - if suffix is null.
hashCode()
Declaration:
public int hashCode()
Description:
Returns a hashcode for this string. The hashcode for a String object is computed as
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
using int arithmetic, where s[i] is the ith character of the string, n is the length of the string, and ^
indicates exponentiation. (The hash value of the empty string is zero.)

Overrides: hashCode in class Object
Returns: a hash code value for this object.
indexOf(int)
Declaration:
public int indexOf(int ch)
Description:
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 of the first
such occurrence is returned —- that is, the smallest value k such that:
this.charAt(k) == ch
is true. If no such character occurs in this string, then -1 is returned.
Parameters:
ch - a character.
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.
indexOf(int, int)
Declaration:
public int indexOf(int ch, int fromIndex)
Description:
Returns the index within this string of the first occurrence of the specified character, starting the search at
the specified index.
If a character with value ch occurs in the character sequence represented by this String object at an index
no smaller than fromIndex, then the index of the first such occurrence is returned—-that is, the smallest
value k such that:
(this.charAt(k) == ch) && (k >= fromIndex)
is true. If no such character occurs in this string at or after position fromIndex, then -1 is returned.
There is no restriction on the value of fromIndex. If it is negative, it has the same effect as if it were zero:
this entire string may be searched. If it is greater than the length of this string, it has the same effect as if it
were equal to the length of this string: -1 is returned.
Parameters:
ch - a character.
fromIndex - the index to start the search from.
Returns: the index of the first occurrence of the character in the character sequence represented by this
object that is greater than or equal to fromIndex, or -1 if the character does not occur.
lastIndexOf(int)
Declaration:
public int lastIndexOf(int ch)

No comments:

Post a Comment