1. Exam Points
Algorithms to manipulate strings
- find if one or more substrings have a particular property
- determine the number of substrings that meet specific criteria
- create a new string with the characters reversed
Note:
- Use specific example values when necessary.
- Index of a string starts with 0 and ends with length-1
- Valid index: 0 to length
- An index of -1 or > length will cause errors (IndexOutOfBoundsException)
- Get 1 characters: substring(index, index + 1)
- Get n characters: substring(index, index + n)
2. Knowledge Points
(1) Implementing String Algorithms
Pay attention when manipulating strings:- get EF from string ABEF
- str.substring(2,4)
- valid index in string ABEF
- 0 to 4 (0 to length)
- invalid index: index<0 or index>length
- get one character
- str.substring(i, i+1)
- get n characters
- str.substring(i, i+n)
- get EF from string ABEF
- There are
standard string algorithmsto:-
- find if one or more
substrings have a particular property
- Ex. count consecutive pairs in a string : abbcdddeff
- find if one or more
-
- determine the
number of substringsthat meet specific criteria
- Ex. determine the number of ABCs in string ABCdeABCffABC
- determine the
-
- create a new string with the characters reversed
- Ex. print the
reversed stringof ABCD, that is DCBA
-