Left hand side of the argument

Converting code from P5.js. In the original code I had an array which can be flexible in p5 which I used to store the location of the Objects I’m working with, and In my function I would call the location in the array and change the Object to another Object when a condition was met. This worked fine.

In Processing I’m now attempting to use ArrayLists to do the same this and I would have thought the same logic applied, However I receive a “left hand side of the argument must be a variable”.

To clarify this is an assignment I’m making in a for loop.

void djikstra(){
  if(pathfind.toggle==1&&target!=null&&pathfinder.get(0)!=null){
     target.visited = true;
     target.pcol2 = color(255,0,0);
     target.fillc();

     for( int i=pathfinder.size()-1;i>-1;i--){
       pathbackup.get(0).pcol2 = color(0);
       pathfinder.get(i).pcol2 = color(0,0,0,150);
       stroke(0);
       //strokeWeight(1);
       //line(pathfinder.get(i).x,pathfinder.get(i).y,target.x,target.y);
       strokeWeight(0);
     if(pathfinder.get(i)!=null&&(pathfinder.get(i).y!=target.y||pathfinder.get(i).x!=target.x)&&!completed){
     searching = true;
     TP next = pathfinder.get(i).find(target,false);
     pathfinder.get(i).visited2 = true;

     if(next!=null){
     next.pcol2 = color(0,0,0,150);
     next.depth = pathfinder.get(i).depth;
     pathfinder.get(i).highlight();
     pathfinder.get(i).visited3 = false;
     stack2.get(i).add(pathfinder.get(i));
     pathhist.get(i).add(pathfinder.get(i));
     
 //---------*Offending Code Here*--------------------------------------------------------------
     pathfinder.get(i) = next;
     }
     else if(stack2.get(i).size()>0){

     TP next1 = pathfinder.get(i).find(target,false);
     if(next1){

       if(!pathfinder.get(i).visited3){
         pathfinder.get(i).pcol2 = color(0,0,0,150);
       }
       else{
         pathfinder.get(i).pcol2 = pathfinder.get(i).pcol;
       }}
     else {
       pathfinder.get(i).visited3 = true;
       pathfinder.get(i).pcol2 = color(0,0,0,0);
     }

     trimpathStack(stack2.get(i));
     pathfinder.get(i) = stack2.get(i).pop();

      }
    }
     else{
         fill(255);
         text("success",10,10);
         searching = false;
         pathfinder.get(i).completed = true;
         completed = true;
     }
     if(pathfinder.get(i).completed){


     }
     if(completed&&!pathfinder.get(i).completed){

     }
 }}

};

Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/List.html#set(int,E)

1 Like