• Post Reply Bookmark Topic Watch Topic
  • New Topic

non-static reference in singleton  RSS feed

 
Ravi Bansal
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

in the below code, if i declare map variable as a static member of Config Class ,will it really change the behaviour of this class in any scenario as the Config Class is singleton?



 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case, you will only have one Map, whether the reference is static or not. However, if you decide to make the class a non-singleton in the future, having the Map as an instance variable is a better idea.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!