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.


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


Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 0674-2361252