In the last article, I have talk about several data types and a little bit of "variable". In this article, I will try to explain what is variable and how to assign value to it.
1. Variable
So, what is a variable?. Variable is some kind of a "placeholder" that will hold data / value. Let us use a box as the example, a box is something that we usually use to store / hold something. For example, Milkbox is used to hold a milk, toybox is used to hold a toy, etc., you get the idea. In programming, variable is used to hold or store values / datas.
2. Assigning data into a variable
After learning about variable, next thing to learn is to assign value to it. In order to perform this assignment operation, a =
symbol needs to be placed between the variable and the value. In Java, this assignment operation can be done like this:
int hello = 1;
let us break the above coding little by little:
- First of all, the name of this variable is
hello
. - The type of this variable is Integer, because there is a
int
keyword before the variable name. - The number 1 is assigned to the variable since there is a
=
symbol between them.
There you go, you have read my explanation about variable and how to assign value to them. Obviously, this article is quiet short and not practical enough, since we have not write any code on the IDE that have been installed previously. This is because we still talk about the core concept of the programming, and hopefully in the next article we will start writing code.
I hope that my article helps you to getting started in learning Java programming language. You can give this article some comments, as any feedback is very valuable and important to me (also suggest me some ideas that you think I need to cover). Thank you for reading this article, and have a nice day π
References
Top comments (0)