Variable is a memory storage that serves as a placeholder for identifiers. Identifiers are then the name that is assigned to data that is meant for manipulation. When working with java variables, the datatype of a particular variables meant to be observed unless error will erupt.
Ways of declaring a variable:
[Datatype Variable_name = variable;]
Example: int a = 10; or
a = “Tonna”;
b = “Romanus”;
Types of variable
Local Variables: These are variable that are inserted or defined inside any method in Java class and destroys when the method is completed.
Instance variables: These are variables that are inserted or initialized within a class but not inside a method. It can be called up by any method.
Class variables: These are variable that are initialized within a class, outside any method but with a static keyword. The main difference of Class Variable and. Instance variable is that Instance variable is static while Class variable is not.