Non static block in java

    when to use static block in java
    how many times static block is executed in java
    block static java
    when do we use static block in java
  • When to use static block in java
  • Static initializer in java.

    static Keyword in Java

    The static keyword in Java is mainly used for memory management. The static keyword in Java is used to share the same variable or method of a given class.

    Types of blocks in java

  • Types of blocks in java
  • Real time example of static block in java
  • Static initializer in java
  • Static block in java example
  • Instance block in java
  • The users can apply static keywords with variables, methods, blocks, and nested classes. The static keyword belongs to the class rather than an instance of the class. The static keyword is used for a constant variable or a method that is the same for every instance of a class.

    The static keyword is a non-access modifier in Java that is applicable for the following: 

    1. Blocks
    2. Variables
    3. Methods
    4. Classes

    Note: To create a static member(block, variable, method, nested class), precede its declaration with the keyword static

     Characteristics of static keyword:

    Here are some characteristics of the static keyword in Java:

    • Shared memory allocation: Static variables and methods are allocated memory space only once during the execution of the program.

      This memory space is shared among all instances of the class, which makes static members useful for maintaini