Two arithmetic symbols also work on strings, with different meanings. The + operator concatenates (joins) two strings: "snow" + "ball" gives "snowball". The * operator replicates a string a whole number of times: "ab" * 3 gives "ababab". The order of the operands for * does not matter, so 3 * "ab" is the same. Multiplying by zero or a negative number gives an empty string "". Neither operator adds a space for you: "Hello" + "world" is "Helloworld".
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.