Trying out expressions
Let's try using some declarations, assignments, and operators. When we bundle these elements together into some meaningful syntax, we call this an expression. Let's write a quick app to try some expressions out. We will then use Toast and Log to check our results.
Expressing Yourself demo app
Create a new project called Expressing Yourself, use the Basic Activity project, and leave all the other settings at their defaults. The completed code that we will write in this project can be found in the Chapter 7/Expressing Yourself folder of the download bundle.
Switch to the MainActivity.java tab in the editor, and we will write some code. In the onCreate method, just before the } closing curly brace, add this code:
int numMessages;
Directly below the previous line of code, we will initialize a value to numMessages.
Next, add this line of code:
numMessages = 10;
Immediately after the previous line of code and before the }closing curly...