0

When we use keyword static?

15th Mar 2017, 2:03 AM
Alvin Fadli
Alvin Fadli - avatar
2 odpowiedzi
+ 1
It's used it in the class whenever you need to create an attribute which is used by all the instances of the class or even if you don't have any instances. It is also used with methods that access private static attributes and it can be called by the class name without having to create objects of the class. Ex: when you need to create a counter that counts the number of objects created from a specific class
15th Mar 2017, 4:25 AM
Gloria E. Hanna
Gloria E. Hanna - avatar
0
When you want to use your method, without creating instance object of that class.
15th Mar 2017, 2:44 AM
Тарас Метельский
Тарас Метельский - avatar