Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help.....

 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ho dear Friends,
I don't understand what is the second line for?could you please help me to describe second line?
Many thanks,
Elahe
---------------------------
public class DbManager {
private static DbManager oSingle = null;
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that's the start of a Singleton pattern.
This ensures that only a single instance of this class is possible.

Because the constructor is protected (or private), code using this class cannot do this:The user of this class is forced to use the static method that gets the internal instance. The internal instance is also declared static, because the static method needs access to it.In this case, both one and two refer to the same instance, and not two different ones.
[ March 01, 2002: Message edited by: Mike Curwen ]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this from Servlets -> Java in General (Beginners)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic