Spaces:
Running
Running
File size: 603 Bytes
1c7978b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
s.substring(int initialindex), which returns a substring of the string s FROM the GIVEN INDEX TO THE END of the string
s.substring(int startindex, int endindex), which returns the substring 's' of the string BETWEEN the given INDICES
- from startindex
- UP TO BUT NOT INCLUDING endindex
Examples on using substrings:
String str = "abcdefghijk";
// five first characters
System.out.println(str.substring(0,5));
// Characters from third character onward
System.out.println(str.substring(2));
// Characters 3-6
System.out.println(str.substring(3, 7));
Program outputs:
abcde
cdefghijk
defg
|