October 2016
Beginner
520 pages
10h 19m
English
In the previous chapter we briefly mentioned strings and we learned that a string can hold alphanumeric data in anything from a single character to a whole book. We didn't look at declaring, initializing, or manipulating strings. So let's do that now.
Declaring a string variable is simple. We state the type, followed by the name:
String levelName; String playerName;
Once we have declared a string we can assign a value to it.
To assign a value to a string, as with regular variables, we simply put the name, followed by the assignment operator, then the value:
levelName = "Dastardly Cave"; playerName = "John Carmack";
Note that the values need to be enclosed in quotation marks. As with regular ...
Read now
Unlock full access