Add method length() to calculate the length of the string in string object.