Java Variables

What are Variables in Java ?

Variables in any programming language are like containers for storing any type of data. Variables helps us to save the data inside them. Variablesare used to store data during the execution of the program. 

When we store data in a variable then the specified data is stored in the ram with specified name. The variable name is actually the name of the memory location.

variables are containers




There are different types of variables in Java Programming language.

    int - stores integers

    float - stores floating point numbers

    char - stores text such as 'c' or 'C'

    String - stores text such as 'CuriosBaba'

    boolean - stores values with two types - true of false


Declaration of Variables in Java

When we want to store data, the first step is to declare a variable in java. Variable declaration consists of 2 components. 

When we declare a variable, an empty space is allotted in RAM with the specified name. In this case 'num'


variable declaration in java



Variable Initialization in Java

Initialization of variable consists of three components. Variable initialization means that we assign the value to be stored in variable.

Variable initialization can considered as 
                        
                        variable declaration + assign value to be stored


















Post a Comment

0 Comments