What is a variable? A variable is a piece of memory which stores a data value. Thus, a variable has a data type. Primarily there are eight primitive data types in java. We will learn about these in a later post. Variables are typically used to store information which our Java program needs to do its job. This can be any kind of information ranging from texts, codes (e.g. country codes, currency codes etc.) to numbers, temporary results of multi-step calculations etc. You can declare a variable as below - datatype name [ initialization ]; Initialization of a variable is not mandatory in all cases. Types of variables There are three types of variables in Java. We will discuss them one by one. 1. Local variables - They can be declared in a method, constructor, or block. When a method is entered, an area is pushed onto the call stack which contains slots for each local variable and parameter. When the method is called, the parameter slots are initialized