The c example above uses substring(4, 5) to grab the last char. String c = str.substring(4, 5) // c is "o" - the last char String b = str.substring(0, 3) // b is "Hel" String a = str.substring(2, 4) // a is "ll" (not "llo") There is a more complex version of substring() that takes both start and end index numbers: substring(int start, int end) returns a string of the chars beginning at the start index number and running up to but not including the end index.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |