This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes wats the problem in creating mutiple instance for class in this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "wats the problem in creating mutiple instance for class in this code " Watch "wats the problem in creating mutiple instance for class in this code " New topic
Author

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

krishna balaji
Ranch Hand

Joined: Mar 16, 2006
Posts: 31
In this code both object a and b are not created and its giving unexpected output
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: wats the problem in creating mutiple instance for class in this code