• Post Reply Bookmark Topic Watch Topic
  • New Topic

method returning ArrayList  RSS feed

 
pepe fernandez
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.

I'm working in a proyect with DB. There are a method that collect info from the DB and set the info in ArrayList:



I use JOptionPane.showMessageDialog to see if i get info from DB and is added correctly to de ArrayList, and it's works.


Now the ArrayList back the invoker class, this is the method :



Again I use the JOptionPane.showMesageDialog to show the first three positions, but it's not work, the problem, as far as I've seen, is all the positions have the same object saved (exactly the last).

Summarizing the ArrayList have the same objetc (last in DB), there are no problems at run or compile.

I dont know if i writte something bad, or just a noob fail...

Thanks for read!
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, ask yourself this:

How many Director objects do you ever create? How many times does new Director() get executed?

You keep overwriting the same instance.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
pepe fernandez
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you master!!!

As i said: noob fail

Again thanks.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!