Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Singleton class confusion

 
sriram varadharajan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
// here is my singleton class.



//first and only instance of singleton /


//I am thinking this will be same instance as the first one.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch. Please UseCodeTags the next time you post some code. I've added them for you this time.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you run two different programs ? If so, the value of the singleton is not going to be persisted anywhere. When the first application ends, everything is gone. What you should try is :
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic