开发者

Variable accessible to all instances of a class

开发者 https://www.devze.com 2022-12-22 00:19 出处:网络
Let\'s say I have a lookup table which I\'d like to make accessible to 开发者_StackOverflowall instances of Foo. Should I make the table private static? If not, what should I do?

Let's say I have a lookup table which I'd like to make accessible to 开发者_StackOverflowall instances of Foo. Should I make the table private static? If not, what should I do?

Basically I want a way to save just one copy of the table (so it doesn't consume extra memory for each instance of Foo) and have it available privately to all instances of Foo.


That sounds like private static to me.

0

精彩评论

暂无评论...
验证码 换一张
取 消