![]() VariableName = Value Ī data type indicates what sort of value or the type of data the variable can represent, such as integer, floating-point numbers, character, boolean or an alphanumeric string. Putting an initial value is referred to as Initializing the Variable. The initialization of a variable is very important before using the variable for any sort of operation. Before that, you would not be able to use the variable. Initialization of Variables: Once the variable declaration is done, then a value can be stored in the reserved memory location. This process is called as Variable Declaration. The name of the variable is called the Identifier. So that next time when you refer to that name, the compiler would know what piece of memory you are referring to. Give the name of your choice to the variable and let the compiler know about it. To effectively handle this transaction, the compiler would need two pieces of information from the program: name and data type of the variable. Naming Variables: After variable declaration, when the program needs the stored value, the compiler will go to the memory location to fetch the value and pass it back to the program. As compiler would like to know the data type of the variable so that it can allocate only required memory to the variable. That can be done by ' declaring the data type' of the variable. How Variables work?ĭeclaring Variables: Ask the compiler to allocate some amount of memory to the variable for storing some value. Each variable in the program has its space allocated in the memory and based on the data type, the system allocates only required memory to the variables.Įvery variable in the program has its name and data type. Information can be of any data type such as int, string, bool or float. In technical terms, a variable is a reserved space or a memory location to store some sort of information. When compiler runs the program, variables used in the instructions are replaced with the real data entered by the programmer. Rather than entering data directly into a program, a programmer can use variables to represent the data. ![]() Data can be constants or fixed values that never change and it can be variable that can change during the execution. A simple computer program uses a set of instructions and data. What is Variable?Īs its names suggest, variable is a value that can change. This chapter is critical and please go through the details and practice the exercises given below related to Data types and Variables in Java. Having a good understanding of Data types and variables is the basic step towards understanding programming.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |