Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Can you please explain me difference between singleton pattern and object created through Static keyword.What are the advantages of singleton pattern.
- Arya
Pankaj Sir, your blog help me lot to understand the basic concept of JAVA. Thank you sir .
- Sumit hazra
Hello Pnakaj Sir, First i would like to thank you for very good blog in every concept in java. Here i have one question related static block and static variable. what is the load first static block else static variable. “My understanding is first static variable will be loaded”. But i am confused for below code please help me. In the below program i have declared static block first. public class StaticRud { static { a = 20; } private static int a = 10; public static void main(String[] args) { System.err.println(StaticRud.a); } } Out put is : 10 ============================= and in the below code i have declared static variable first public class StaticRud { private static int a = 10; static { a = 20; } public static void main(String[] args) { System.err.println(a); } } Out put is : 20 Is there any way to declare static variable before or after static block? Please help me sir.
- Sahdev
Is it possible to implement static methods in interface before Java 8 ? What is the improvement that would be brought in with this change in Java 8 static mehtods in interface.?
- Davinder
Why static block is needed , though we can intialize static variables at the time of declaring static variable
- Gurpreet Singh
Static Variable and Static Block are executed before Main method gets executed,but Static Variable and Static Block are executed based on the order we are declare from top to bottom
- Sonia
Hi, I know that, for the sake of your example, you created a StaticExample() object (se) to compare its .count with StaticExample class .count object . My question is: don’t you need a constructor to create an object? Thanks
- Emanuele
Hi, I need to ask you a question after reading How do you gain your knowledge as you answered from video tutorials and some e-books so If I depend on your blog to gain my knowledge it will be not enough to be a good java developer and crack java interviews, Thanks in Advance
- mossama
this article is very useful. it clear all the doubts about static keyword in java. thank you
- Anurag Singh
hi Pankaj, thanks for great article T i have question please answer me if we have static gloabal object, where store in memory??? heap or …??? generaly static object different place stored than another object ??? please cleear me
- milad