0

What is the use of static keyword ?

26th Nov 2016, 11:07 AM
Suraj Anbhule
Suraj Anbhule - avatar
4 Antworten
+ 12
Static members belong to the class instead of a specific instance. It means that only one instance of a static field exists even if you create a million instances of the class or you don't create any. It will be shared by all instances. Since static methods also do not belong to a specific instance, they can't refer to instance members.
26th Nov 2016, 11:40 AM
Remmae
Remmae - avatar
+ 1
once declared used throughout the program... initialized as 0... can access via static member function....
6th Dec 2016, 2:11 AM
Dhiraj singh✔️
Dhiraj singh✔️ - avatar
0
Static methods and variables are shared across all the instances of a class. If you change the value of a static variable it'll be changed throughout the application. Static members can be accessed without creating any instance of the class. Static methods cannot access any instance members. Static blocks are used to execute some code only once when that particular class is loaded by the jvm (classloader).
27th Nov 2016, 7:27 PM
Sourav Kumar Ghosh
Sourav Kumar Ghosh - avatar
0
Static in its most basic terms means that it's shared across the class and when it's changed everything that uses it sees the change.
5th Dec 2016, 6:23 PM
Bryan
Bryan - avatar