Look at the tutorials:
Assignment, Arithmetic, and Unary Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)
also ask google
Type: Posts; User: Norm
Look at the tutorials:
Assignment, Arithmetic, and Unary Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)
also ask google
There is a shortcut operator (+=) that you can use to add one variable to another:
theTotal += aDetail;
instead of
theTotal = theTotal + aDetail;
Define a separate variable to hold the sum of the numbers.
Add each number that is read to that variable.