Something of a class type is an object with methods as well as a value. So String objects have associated String methods which can be used to manipulate string values. As with any method, the method is invoked by writing a dot and the name of the method after the object name. Any arguments to the method are given in parentheses. In today's lab we wish to explore some common String methods.
Position is a non-negative integer.
Returns -1 if string2 not found. Try to understand the effect of each method call. Add appropriate comments to the code. It was the best of times. Read a string and count the number of occurrences of a particular character, for example 'a'.