What is the use of static block in Java?
Static block is mostly used for changing the default values of static variables.This block gets executed when the class is loaded in the memory. A class can have multiple Static blocks, which will execute in the same sequence in which they have been written into the program.
-----------------------------------------------
What is static initialization in Java?
The static initializer is a static {} block of code inside java class, and run only one time before the constructor or main method is called
===============================================
//Static block and initialize block
class X
{
//Static block
static
{
System.out.println("This Is A Static-2");
}
// initialize block
{
System.out.println("this is initialize block");
}
X()
{
System.out.println("OBJ Create");
}
public static void main(String []s)
{
System.out.println("Start");
System.out.println("End");
}
static
{
System.out.println("This Is A Static-1");
}
}
===================================
static initialization block in java,
java static initializer block hackerrank solution,
why static block executed first in java,
java initializer block,
java initialization block vs constructor,
static initialization c++,
java instance initializer,
non static block in java,
www.saprahits.com
www.patelwala.com
www.readranks.com
~-~~-~~~-~~-~
Please watch: "How to online money earn from Flipkart without selling any products"
• Video
~-~~-~~~-~~-~
En esta página del sitio puede ver el video en línea Static and initialize block in JAVA de Duración hora minuto segunda en buena calidad , que subió el usuario Inside App 14 febrero 2017, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 222 veces y le gustó 2 a los espectadores. Disfruta viendo!