posted 15 years ago
Hi everyone. I'm sorry the dumb question, but I don't know why this is happening.
I have the following code:
Ok. It works, but I'm trying to create a List of FuncaoDePertinencia like this:
a = 1, b = 1, c = 1, d = 1
a = 2, b = 2, c = 2, d = 2
But it comes like this:
a = 2, b = 2, c = 2, d = 2
a = 2, b = 2, c = 2, d = 2
I believe that that happens because the reference variable chages and the List changes everything that has the same name of the reference variable. Am I right? Or completely wrong?
Now, I'm solving this problem creating a differente reference variable for each FuncaoDePertinencia object that I'm adding in the ArrayList. So, if I'll have 100 FuncaoDePertinencia object, I'll have 100 diferent variables (named f1, f2, ..., f100).
What's the real good way non-foolish-correct-and-elegant to solve this?
Cumps from Brazil.
I'm sorry my english. It's not very good.
Hugs.
Andre.
[edit]
Oooopz. Now I figure it out that I could write something like this:
Sorry. My bad.
[/edit]
[ November 02, 2008: Message edited by: Andre Brito ]
[ November 02, 2008: Message edited by: Andre Brito ]
[ November 02, 2008: Message edited by: Andre Brito ]