Java Static Initializer Block

  • + 1 comment

    No You can't do that because we need to reference the variables in main method,as main method is non-editable.so the only option you have that while compiling, when JVM loads (.class) file in the memory intialize all those variables at the same time that can be done when you declare variables as static.

    • + 0 comments

      Thanks, that helps a lot to understand how it works