Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wats the problem in creating mutiple instance for class in this code

 
krishna balaji
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this code both object a and b are not created and its giving unexpected output
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by krishna balaji:
...In this code both object a and b are not created and its giving unexpected output

How are you getting output if neither object is created?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One likely cause of your troubles is that the member "m" in confserver is static, but it's assigned in the constructor. That means each time you create a confserver, any previous value of m is lost, and all confserver objects share the latest one.

If I may: Java programmers universally use capital letters to name classes; for example "ConfServer". Using all-lowercase class names makes your code exceedingly hard to read for an an experienced programmer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic