• Post Reply Bookmark Topic Watch Topic
  • New Topic

Singleton vs Static  RSS feed

 
Niyas Ahmed Sheikh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I had found this faq from theserverside.com. Below is that FAQ:



My question is whether it is poosible to create more than one instance for static class. I tried it is working. Whether I had done it correctly?

 
Qi Liang
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The staic class is generally used as static nested class like "In" in you code. The methods in static nested class can not access the member of outer class.



Also, I do not think static class just has only one instance. It can have more than one instance.
 
Steve Simon Joseph Fernandez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I don't think your code proves anything about the existence of multiple objects of the static inner class, however:



Output: false

proves that the two objects obtained are different, as expected.

_steve.
 
Niyas Ahmed Sheikh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So we can have more than one instacnce for static class.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If y'all are interested in the rest of the story:

http://www.javaranch.com/campfire/StoryInner.jsp
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!