0
What is static block?
What is static block in Java, on which condition it is used in real world. Please provide some of real world example
3 Réponses
+ 3
we can use the static keyword with a block of code that is known as a static block. A static block can have several instructions that always run when a class is loaded into memory. It is also known as java static initializer block because we can initialize the static variables in the static block at runtime. A class can have any number of static blocks, The JVM executes them in sequence in which they have written. The static block in a program always executed first before any static method, non-static method, main method, or even instance block.
+ 1
Specify a language and some more details about your question
Edit: The question is edited
+ 1
If you define a static keyword you can access that without making its object like public static void main in java, we can use this class without making its object