• Post Reply Bookmark Topic Watch Topic
  • New Topic

issue with object overwriting itself when I need it to create separat instances(nevermind I got it)  RSS feed

 
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code:



It first creates a new DeviceChannel Object, which is the one I need multiple instances of. It then passes a url value to a method in ordeer to get xml from a web service and populate the Device class with it. I then create a list called dc that holds DeviceChannel Objects. Then i do operations to fill the DeviceChannel class with values, add it to eh dc List, and then add that List to another List in another class.

At the end it prints out the name of the deviceName and the representation of the Object holding that deviceName.

The deviceName prints out two different deviceNames like it is suposed to, but for some reason the print out of the DeviceChannels Object representation is always the same Object, not two separate Objects as intended.

ANy idea where I need to change this?










Here is the full code if you want to see it, it has the above for loop nested in another for loop. The first one sets the projectName in a class, and the second for loop I am having issues with is intended to set a List that is in that same class, so I will end up with an Object that has a projectName, and a List of Objects. Everything works except the list of DeviceChannel Objects, because the second iteration is overwriting the first leaving me with two of the same DeviceChannel Objects in my List.,:



 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!