Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

Variables in Java

Java variable is nothing but a named memory allocation which may vary at the time of execution.A variable assigns a value.

For example, int x=20;
Here x is a variable and the value 20 is assigned to x which is also known as variable initialization.

Basically Java supports three types of variables, such as :

  1. Local variable
  2. Instance variable
  3. Static variable
Local Variable:

A variable that is declared inside the method is called local variable.

Instance Variable:

A variable that is declared inside the class but outside the method is called instance variable .

Static Variable:

A variable that is declared by the keyword static is called static variable. It cannot be local.

Example
class Demo
{
   	int x=30;      //instance variable
   	int y=200;     //static variable
   	void get()
   	{
	  	int z=50;    //local variable
   `}
}

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext