Why are static variables considered evil?

前端 未结 30 2730
既然无缘
既然无缘 2020-11-21 05:04

I am a Java programmer who is new to the corporate world. Recently I\'ve developed an application using Groovy and Java. All through the code I wrote used quite a good numbe

30条回答
  •  礼貌的吻别
    2020-11-21 05:56

    everything (can:) have its purpose, if you have bunch of threads that needs to share/cache data and also all accessible memory (so you dont split into contexts within one JVM) the static is best choice

    -> of course you can force just one instance, but why?
    i find some of the comments in this thread evil, not the statics ;)

提交回复
热议问题