7.16 How to use Static Block in Java Tutorial

preview_player
Показать описание
Printing Something without any statement in Main Method.
Static Blocks are called before main Method.
Static Blocks are called as soon as your class is loaded in JVM.

Static block is a block of code which is preceded by the static keyword. Static block are also called

initialization block .It can be used to print something without any statement in Main Method.

Static Blocks are called before main Method.

Static Blocks are called as soon as your class is loaded in JVM.

Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

For More Queries about Course, WhatsApp or Call: +919008963671

Subscribe to the channel and learn Programming in easy way.

Рекомендации по теме
Комментарии
Автор

Lol..someone is doing pooja in the background..desi will relate..nice tuts btw..

javadoctor
Автор

Navin sir you r awesome😃😃😃😀apun ko programming smj arahi ha ab 😄😄Thank you so much

Sunny_sharma
Автор

Thank you Telusko. You have done a great job!I learned a lot.

thestarinthesky_
Автор

You made java very easy for me
Thanks 🙏

prasadsardesai
Автор

sachin tendulkar: made batting look so easy ..
navin reddy: made java look so easy

karrinagasatyanarayanaredd
Автор

Would be better if you can increase your pitch a bit. With my laptop volume full, still I am facing issues in hearing!

mayankmaheshwari
Автор

Does this mean static block is always called first, even before main(). It was interesting to know :)

swaminathbera
Автор

@ 5:30 you said we cannot use constructor for manipulating static variables, but as constructor is non - static member method we can access a static variable within a non-static member function, isn't it

souvikpal
Автор

we can initialize static variable in main method too.

sweatheart
Автор

can we do multiplication like 10*5 without using any arithmetic operator?

mohitmishra
Автор

But we can initialize the static variable at the time of declaration itlself? Why we need stattic block

pulkitsharma
Автор

But in the previous lecture 7.15 i.e. count number of object, constructor worked on static variable as it has increases the count of i. Please elaborate

deepaligupta
Автор

so most of your examples can be executed in the static block itself, with a blank main method. what are the intended application of these static blocks?

TheSumit
Автор

Is it compulsory to write main function? Because static is already writing hello world

naoyoshino
Автор

sir the volume in the video is a bit on the lower side

tanmaykumar
Автор

Then we can write out code in static only no sir? Why we can write in public static void main?

abhishekabhi
Автор

Can't we directly initialize a static member without using static block?

abhishek_sengupta
Автор

thanks for this video but plzz tell can we not use static methods to give a value to static variables
if yes whats need of static block

aarushigupta
Автор

Your explanations are very good but we need more practical examples apart from demo and hello world 😃

unmeshchougule
Автор

Simple question .first without writing any static string both static block executed 1st & then main, & after using static string first main get executed then static block why??

amitashah
welcome to shbcf.ru