Java Reference
In-Depth Information
substring
public String substring (int beginIndex,
int endIndex)
Returns a new string that is a substring of this string. The substring begins at
the specified beginIndex and extends to the character at index endIndex - 1 .
Thus the length of the substring is endIndex - beginIndex .
Examples:
"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile"
Parameters
beginIndex —the beginning index, inclusive.
endIndex —the ending index, exclusive.
Returns
the specified substring
Throws
IndexOutOfBoundsException —if the beginIndex is negative, if
endIndex is larger than the length of this String object, or if beginIndex
is larger than endIndex .
Some of the methods in the API specs are marked as deprecated.
Deprecated
Discouraged from use.
Deprecated items are ones that Java's designers want to discourage you from
using. Generally these are methods that Sun has either renamed or decided shouldn't
be called because they didn't behave correctly or safely. You might think that Sun
should just remove these deprecated methods from Java, but doing so would break
any older Java programs that call these methods. An example of a deprecated method
is the inside method in the Rectangle class of the java.awt package:
inside (int x, int y)
Deprecated. As of JDK version 1.1, replaced by
.
contains(int, int)
Writing Javadoc Comments
If you write your comments in a special style called Javadoc, they can be used to
automatically produce web pages like those in the API Specification. In fact, Sun
generates the API Specification by writing Javadoc comments in each class of the
class libraries. The syntax to signify a Javadoc comment is to begin a multiline com-
ment with /** rather than the usual /* :
 
 
Search WWH ::




Custom Search