Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

In what scenario do we use a static block?

Pragya Keshap answered on February 4, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • static block in java
  • what is the use of static blocks in java
  • what is use of static block in java
  • static block in java
  • Implement the static keyword – static variable, static block, static function and static class with following conditions
  • static block in java
  • What is the static block

  • In what scenario do we use a static block?

    0

    At times, there is a class that has static member variables. 

    These variables need some complicated initialization.

     At this time static block helps as a tool to initialize complex static member variable initialization.

    The static block is executed even before the execution of main.

    Sometimes, we can also replace static block with a static method of class.

    https://www.scaler.com/topics/static-block-in-java/

    Popularity 1/10 Helpfulness 1/10 Language java
    Source: Grepper
    Tags: java
    Link to this answer
    Share Copy Link
    Contributed on Feb 04 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.