What is the difference between static int variable and normal int variable?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

What is the difference between static int variable and normal int variable??

2nd Sep 2017, 11:45 AM
Harsha Sanju
Harsha Sanju - avatar
6 Answers
+ 2
it's okay. 😃
2nd Sep 2017, 12:12 PM
Zeron
Zeron - avatar
+ 2
This depends entirely on the context. For example, a static global variable does not mean the samething as a static variable inside a function.
2nd Sep 2017, 1:04 PM
aklex
aklex - avatar
+ 1
static variables can only be declared in the class but must be outside the block statement and you can access the static variable without creating the object first. normal variable? what you mean local variables, if yes, local variables can only be declared in block statements like method / if / else / etc and the local variable's active period is inside the statement block itself.
2nd Sep 2017, 12:07 PM
Zeron
Zeron - avatar
+ 1
OK thank u Zeron
2nd Sep 2017, 12:10 PM
Harsha Sanju
Harsha Sanju - avatar
+ 1
OK squared... thank u
2nd Sep 2017, 12:53 PM
Harsha Sanju
Harsha Sanju - avatar
+ 1
OK aklex
2nd Sep 2017, 1:07 PM
Harsha Sanju
Harsha Sanju - avatar