Variables in Java Programming

In this tutorial we will study what is variables in java and what’s are the type of variable in java programming. So lets go in the deep model.

What is variable

A variable is a storage area where we store the data and the information. A variable is a holder which holds the value while the java program is executed. Variable also declare with a data type. When we declare a variable name the first letter of the variable should not be a digit. And the variable name should not be a keyword.

Types of variable:-

1. Local Variable:-

A local variable always declares inside the body of the method and function. A local variable can be a static variable. Local variable should be initialized before accessing them.

2. Instance Variable:–

A variable that is declared inside a class but outside the body, method, constructor or block, is called instance variable. Instance variable need not be initialized before using them as they are automatically initialized to their default values.

3. Static Variable:-

A variable which is declared with the static keyword, Static variable is stored in the static memory. A static variable is regular to every one of the occasions (or objects) of the class since it is a class-level variable. you can say that only a single copy of the static variable is created and shared among all the instances of the class. Memory designation for such factors possibly happens once when the class is loaded in the memory.

Use My Notes is an Education Website for providing all Technical course material. https://usemynotes.com/