Variables in Java

A variable is a name or label given to the storage that holds data. We use variables to store data such as name, age, credit card info etc. which can be used later in our application to perform operations.

Declaring variables

<type> <variable_name>;

int a;
int b;
String name;

<type> <variable_name>  = <value>;
int a = 10;
int b = 20;
String name = "java programmer";

Java is a strictly typed language which means that you have to define the type of data the variable is going to store during the time of declaration;

eg: int a;

here int represents the type of data which will be stored by the variable a

Leave a Reply

Your email address will not be published. Required fields are marked *