Changing values in variables with operators
Of course, in almost any program, we are going to need to do things with these values. We manipulate (change) variables with operators. Here is a list of perhaps the most common Java operators that allow us to manipulate variables. You do not need to memorize them as we will look at every line of code as and when we use them for the first time. We have already seen the first operator when we initialized our variables but we will see it again being a bit more adventurous:
The assignment operator (=): This makes the variable to the left of the operator the same as the value to the right. For example,
unreadMessages = newMessages;
.The addition operator (+): This adds together values on either side of the operator. It is usually used in conjunction with the assignment operator, or slightly differently; add together two variables that contain numeric values. Perhaps like this
unreadMessages = newMessages + unreadMessages;
oraccountBalance = yesterdaysBalance...