REMINDER: substring - ending index is exclusive! => "S".equals("String".substring(0,1))
Parameters
startIndex : starting index is inclusive, and starts at 0
endIndex : ending index is exclusive
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#substring(int,int)
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html
https://www.javatpoint.com/java-string-substring
"north".substring(0,1) => "n"
"north".substring(1,2) => "o"
"north".substring(1,3) => "or"
"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile"
Signature:
public String substring(int startIndex)
and
public String substring(int startIndex, int endIndex)
If you don't specify endIndex, java substring() method will return all the characters from startIndex.
Parameters
startIndex : starting index is inclusive, and starts at 0
endIndex : ending index is exclusive
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#substring(int,int)
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html
https://www.javatpoint.com/java-string-substring
"north".substring(0,1) => "n"
"north".substring(1,2) => "o"
"north".substring(1,3) => "or"
"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile"
Signature:
public String substring(int startIndex)
and
public String substring(int startIndex, int endIndex)
If you don't specify endIndex, java substring() method will return all the characters from startIndex.
No comments:
Post a Comment