Problem with array
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Saturday, March 9, 2002 11:18 AM

Hi, I have made a class with one attribute that is a array of another class; the code is: Dia setm[] = new Dia[7]; I initialize any object of the array, and in the code I asign a value of Dia class at any array elements. The problem I have is that all of the elements of the array get the value of the last assignation I made... An exemple code of what I make is: setm[0] = dia0; setm[1] = dia1; setm[2] = dia2; setm[3] = dia3; setm[4] = dia4; setm[5] = dia5; setm[6] = dia6; and dia1... dia6 have different values. At the end setm[0], setm[1]... setm[i] have the same    More>>

Hi,


I have made a class with one attribute that is a array of another class; the code is:


Dia setm[] = new Dia[7];


I initialize any object of the array, and in the code I asign a value of Dia class at any array elements. The problem I have is that all of the elements of the array get the value of the last assignation I made...


An exemple code of what I make is:


setm[0] = dia0;

setm[1] = dia1;

setm[2] = dia2;

setm[3] = dia3;

setm[4] = dia4;

setm[5] = dia5;

setm[6] = dia6;


and dia1... dia6 have different values. At the end setm[0], setm[1]... setm[i] have the same value, dia6!!


Anyone knows why??

Thanks to all in advance!!

   <<Less

Re: Problem with array

Posted By:   Ara_Abrahamian  
Posted On:   Saturday, March 9, 2002 11:30 PM

And why are you asking it in XDoclet's forum? Ask this question in JavaLanguage forum. You won't get an answer in this forum.



Ara.

About | Sitemap | Contact