We frequently use variables and data types in our programs. It is even difficult to imagine an application without these two fundamental concepts. Now, the question is "What are variables & data types and why do we use them in our programs?". Variables are generally considered to be memory to keep data. However, suppose you are writing a program which uses some data, then you must need some memory to store this data. So variables are used to reserve memory for storing data and those reserved memory locations are identified by the name of the variable. Note: If you are familiar with the 'C' or 'C++' Language, you may know how to get the memory address of a variable, but you don't do that in Java. I hope it is now clear "what is the use of variables". Now, what about "how much memory should be kept or reserved". Variables can't be used directly to reserve memory. One must also specify the Data Type with the variable name to ensure the amount of memory to be kept to store the data. The variable is restricted to hold only a specified type of data; when you assign another type of data to a variable then the output may be undesirable or garbage. Syntax to declare a variable [data type] [variable name]; For e.g.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: