Can any1 explain the use of static keyword? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Can any1 explain the use of static keyword?

12th Apr 2016, 10:18 AM
Tanvi Singhal
Tanvi Singhal - avatar
2 Respostas
0
sometimes we want a local variable NOT to be deleted. We need it for a further job. To do this, use the static keyword when you first declare the variable:
28th Apr 2016, 6:53 PM
sourabh kale
sourabh kale - avatar
0
declaring a variable static ensures that the variable retains whatever value it has after it is out of scope. This means that if u declare a static variable in a function and assigns some value to it when u recall the function the last value stored in the variable is still there it wont be reset to the initial value
12th Jun 2016, 5:11 PM
Oneil Pinnock