Share this post on:

Static keyword in Java is used for declaring class attributes and behavior that is static keyword represents class.

It is same to global variable of other languages. Static keyword in java is used for memory management.

Static keyword is used as three ways.

  1. Static data keyword
  2. Static block
  3. Static method

In Java there are three types of memory:

  1. Stack Area : All the local Variable of a methods or constructor can be store in Stack Area.
  2. Heap Area : All the Objects are created in Heap Area.
  3. Class Area : All the Static data member are created in Class Area.

Static Data Member : It Represents class Attributes. Static keyword is used to declaring static data member. static data member executed only one that is created only once and all the object of a class can share that single copy of static data member, that is static data member is common for all objects of that class.


class first


static int a=5;

int b;

public static void main(String[] args)


first x=new first();

first y=new first();



Static Block : It is also called static initializer block. It is mainly use to initialize static data member. static block executed only once but automatically.





Static Method : When a simple method is associated with static keyword known as static method. static method can be executed without creating class object that is it can be executed with it class name only.


private static void example()



Share this post on:
Avatar Raiyan

Author: Raiyan

Hi, I guess you're here because you want to know a bit about me. huh? I am not so good on talking about myself but I'll give a short about me.

My Name is Raiyan. I am a Professional Application Developer and a Blogger.
I started this website to Share my Knowledge. Here I provide all my knowledge whatever I earned till now.

One Comment

  1. Pingback: What are Important topics in java Interview? - ArzaTechs

Leave a Comment

Your email address will not be published. Required fields are marked *