Java Static Initializer Block

  • + 1 comment

    hey I am new to JAVA but why we use static cant we do it without static?

    • + 1 comment

      No u cant do it without static. As static members load into memory before anything else. So if the flag variable is not declared static then main wont have any value of flag! and thus an error my friend :)

      • + 0 comments

        Exactly!