0

What is the use of static?

27th Sep 2016, 7:27 PM
Surya Swanoff
Surya Swanoff - avatar
3 Answers
+ 4
"static" says the function work on its own
28th Sep 2016, 1:42 PM
Domasian arvin karl
Domasian arvin karl - avatar
+ 3
static methods and variables are tied to the class, not the object. There are also static classes which means no instantiation is necessary. (no new objects). The obvious example of a static method is the main method. It wouldn't make sense to be able to create a new "main" object.
28th Sep 2016, 2:37 PM
Mythos
+ 3
static keyword indicates either it is a class method, class variable. Remember class cannot be static and final.
3rd Nov 2016, 6:28 PM
Jenny Lance
Jenny Lance - avatar