maxtek IoT

Variable

Before delving into the concept of variable in computer science, let us go back to primary school.
I still have a bright memory of my childhood, that is the way i am taught to add two numbers. First draw two boxes and count the value of each digit in each box using a horizontal bar symbol. Next, draw the last box in which you add all the horizontal bars in each symbol and find the by counting the number of the symbol bars.

With regard to programming, those boxes i mentioned early are called variable in computer. In fact, a variable is a location in the computer's main memory (RAM) where you can store a value and change it as the program executes.

So in Java, the syntax to declare and to store a value in a variable is:
data type + variable name = value;

Notice that the sign = is call the assignment operation which means store a value on the right hand sign of the operator into the variable in the left hand side by stating the data type of the value to be stored into that variable. Besides, each statement is terminated with a semi colon ;

for instance if you want to assign values 56, 14 and 70 to three variable, here is the syntax:
int x=56;
int y=14;
int z= 70;