I have one static member in non static class - if I will initialize this field with some value - does other (new) instances of this class will have the same value in this field?
Asked
Active
Viewed 190 times
0
-
2Could be a good interview question. I doubt how many people know this. :) – Dhrumil Jun 11 '15 at 10:46
-
@HarveySpecter true that :) – fsacer Jun 11 '15 at 10:47
-
3`Static` means independent of instances. Does that answer your question? ;-) – Tim Schmelter Jun 11 '15 at 10:48
-
Yes, all right thank you)) – curiousity Jun 11 '15 at 10:48
1 Answers
1
Yeah all instances of the same class share the same value of static member.

fsacer
- 1,382
- 1
- 15
- 23
-
1I suspect you mean "all instances" - and it's not that each instance has the same value, it's that the variable is associated with the type, not *any* instances. – Jon Skeet Jun 11 '15 at 10:48