First, we define an alphabet. An alphabet is a set of characters. An alphabet doesn't have to resemble the English alphabet. For example, { '0', '1' } could be an alphabet. It just has two characters.
A string is zero or more characters from the alphabet.
We write strings starting with a double quote (called the open quote) and ending with a double quote. The quotes are not part of the string. They only tell you where the string begins and ends.
Here are examples of valid strings: "", "ab", "The quick brown fox jumped over the lazy dog".
"" is called the empty string.
If we have escape sequences in the alphabet, then they count as one character. Thus, "\n\n\n" has length 3. Yes, you typed 6 characters, but when Java runs the program, it treats '\n' as one character, not two. "\\\\\\" also has length 3 (there are three escaped backslashes in this string).
Thus, in "ca\nt", we have 'c' at index 0, 'a' at index 1, '\n' at index 2, and 't' at index 3. Again, notice how escape sequences only count as one character.
Notice that we don't put the single quotes in the string.
It may seem strange that the end index is not the index of the last character, but this allows us to specify an empty string.
Consider the string "tomcatfoolery". "cat" is a substring of this string. It has start index 3 and end index 6 (which is the index of 'f').
On the other hand "tfool" is not substring of "tomfoolery", since there is no start index and end index that exactly picks these letters out (and no others).
The entire string is usually considered a substring of itself.
The empty string is always a substring of any string, even the empty string.
There are two useful operations with substrings. You can ask if some string is a substring of another. You can also give a start and end index to extract a substring from a string.
In Java, extracting a substring creates a new string. The original string is unchanged.
We use the + operator (just as Java does) to concatenate strings. Thus, "slime" + "dog" creates a new string "slimedog". We can concatenate several strings. For example, "slime" + "dog" + "news" evaluates to "slimedognews".
Concatenation creates a new string. Neither of the strings that are operands in concatenation are changed.