This content originally appeared on DEV Community and was authored by karanpatel4795
Static blocks are used for deallocated /substitute default values of static variables of a class.
There are some protocols which drive the functioning of static blocks:
Static blocks will be carry out only once as soon the class is loaded in memory.
They are carry out in the order which they appear in the class.
Inside the static blocks, we can not introduce to any instance variables.
There are numerous static block can be created as you want in class.
Now resume to go alone of execution as soon as Class is loaded the following is performed by the JRE (Java Runtime Environment ):
Static data members (if any) are created.
Static blocks (if defined) are executed.
The task that results in class loading is performed.
Main method is called.
This content originally appeared on DEV Community and was authored by karanpatel4795
karanpatel4795 | Sciencx (2022-02-18T10:26:05+00:00) Static in Java. Retrieved from https://www.scien.cx/2022/02/18/static-in-java/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.