Description:
Obtaining Substrings
String s1 = "Welcome to Java";
Method Description
substring(beginIndex) Returns this string’s substring that begins with the character at the specified beginIndex
and extends to the end of the string, as shown in Figure 4.2.
e.g.
s1.substring(11); // Java
substring(beginIndex,endIndex) Returns this string’s substring that begins at the specified beginIndex
and extends to the character at index endIndex – 1, as shown in Figure 4.2.
Note the character at endIndex is not part of the substring.
s1.substring(0,11); // Welcome to
Share this link via
Or copy link
























