Chapter 10 is all about strings. A bit late, you might think: we’ve had about nine chapters of string-based action already! Well, yes, you’d be right. That’s not terribly surprising, though: text is probably the single most important means an application has of communicating with its users. That is especially true as we haven’t introduced any graphical frameworks yet. I suppose we could have beeped the system speaker in Morse, although even that can be considered a text-based operation.
Even with a graphical UI framework where we have pictures and buttons and graphs and sounds, they almost always have textual labels, descriptions, comments, or tool tips.
Users who have difficulty reading (perhaps because they have a low-vision condition) may have that text transformed into sound by accessibility tools, but the application is still processing text strings under the covers.
Even when we are dealing with integers or doubles internally within an algorithm, there comes a time when we need to represent them to humans, and preferably in a way that is meaningful to us. We usually do that (at least in part) by converting them into strings of one form or another.
Strings are surprisingly complex and sophisticated entities, so we’re going to take some time to explore their properties in this chapter.
First, we’ll look at what we’re really doing when we initialize a literal string. Then, we’ll see a couple of techniques which let us convert from other types to a string representation ...