Static in Java

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.


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.

read more..


This content originally appeared on DEV Community and was authored by karanpatel4795


Print Share Comment Cite Upload Translate Updates
APA

karanpatel4795 | Sciencx (2022-02-18T10:26:05+00:00) Static in Java. Retrieved from https://www.scien.cx/2022/02/18/static-in-java/

MLA
" » Static in Java." karanpatel4795 | Sciencx - Friday February 18, 2022, https://www.scien.cx/2022/02/18/static-in-java/
HARVARD
karanpatel4795 | Sciencx Friday February 18, 2022 » Static in Java., viewed ,<https://www.scien.cx/2022/02/18/static-in-java/>
VANCOUVER
karanpatel4795 | Sciencx - » Static in Java. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/18/static-in-java/
CHICAGO
" » Static in Java." karanpatel4795 | Sciencx - Accessed . https://www.scien.cx/2022/02/18/static-in-java/
IEEE
" » Static in Java." karanpatel4795 | Sciencx [Online]. Available: https://www.scien.cx/2022/02/18/static-in-java/. [Accessed: ]
rf:citation
» Static in Java | karanpatel4795 | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.