Static and initialize block in JAVA

Published: 14 February 2017
on channel: Inside App
222
2

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  
~-~~-~~~-~~-~


On this page of the site you can watch the video online Static and initialize block in JAVA with a duration of hours minute second in good quality, which was uploaded by the user Inside App 14 February 2017, share the link with friends and acquaintances, this video has already been watched 222 times on youtube and it was liked by 2 viewers. Enjoy your viewing!