Reputation: 347
I have an object (sonde(x,y,r,position)) whene i create a list of sonde i want to change value of position i use :
int sizel =arSonde.size();
for(int i=0;i<sizel;i++){
double x1=arSonde.get(i).x;
double y1=arSonde.get(i).y;
double rayn=arSonde.get(i).rayon;
double x2=arrayAction.get(0).x;
double y2=arrayAction.get(0).y;
Random random=new Random();
double D =rand.nextDouble();
double rayA=arrayAct.get(0).rayon;
if(D<rayA){
arSonde.set(pos,5);
}
i used:
list.set(pos,element);
Upvotes: 0
Views: 77
Reputation: 36703
Assuming you're trying set the position attribute of your Sonde object, and given your fields appear to be public...
arSonde.get(i).position = 5;
Your call arSonde.set(pos, 5)
doesn't work because
If Sonde is immutable, or you needed a different instance you could always create a new instance and use the set(index, object) call...
arSonde.set(i, new Sonde(x1, y1, rayn, 5));
Upvotes: 1