In computer programming, counting by one is a valuable way to keep track of iterations through a loop, items in an array, lines of user input and many other finite resources. Because the task is so essential to most computer programs, Java uses a simple operator called the increment operator to streamline the process of adding one to any integer variable. The increment operator adds on to the value stored in the variable and stores the result within the variable.

Define the variable that you will use to keep count. The variable should be an integer and can have any name. The following line of code creates an integer called "count": int count;

Set the variable to the initial value from which you want to begin counting. For example, the following code sets the variable called "count" to 0: count = 0;

Use the increment operator, ++, to increase the value of your variable by one. If the variable count is initially set to zero, the following code increases the value of count to 1: count++;

Repeat the increment operator wherever necessary to continue increasing the value of the variable.

About the Author

David Weinberg began writing in 2005 at New College of Florida, composing articles on history and political science for publication within the school and for online circulation. Weinberg has been a professional outdoor educator for more than five years with experience throughout the United States.