+ 1

When should I use static?!

29th Sep 2017, 1:02 PM
Abdalrahman Elrahma
Abdalrahman Elrahma - avatar
5 Answers
+ 2
thanks
29th Sep 2017, 1:19 PM
Abdalrahman Elrahma
Abdalrahman Elrahma - avatar
+ 1
Usung static makes it belong to the class not each object individually. Image you were creating a blueprint of a house the blueprint might contain a width and hight. These would apply to each house built. A static member is more like properties belonging to the paper the blueprint is written on. No matter how many house you build the original blueprint will always have the same properties. Static should be used when you want one property or method that is shared across everything created with that class blueprint.
29th Sep 2017, 1:29 PM
josh mizzi
josh mizzi - avatar
0
what is an instance?!
29th Sep 2017, 1:16 PM
Abdalrahman Elrahma
Abdalrahman Elrahma - avatar