A pathfinding solution

It is because you declare the variable inside your if statement so it exists only here (If I’m not saying any non sense scope of variables are inside the block they are declared in).

What you should do is actualy declare your variable in the first for loop and then only update the x and y parameter lke so:

for(int a = carn1m.size()-1; a >= 0; a--){
  Carnivor1M c1m = carn1m.get(a);
  PVector target = new PVector(0, 0);
  currentSmallest = (parent.height * parent.height) + (parent.width * parent.width); 

  for(int b = lac.size()-1; b >= 0; b--){
    Lac l = lac.get(b);
    d = ((c1m.position.x - l.position.x) * (c1m.position.x - l.position.x)) + ((c1m.position.y - l.position.y) * (c1m.position.y - l.position.y));
						
    if(d < currentSmallest){
      currentSmallest = d;
      target.x = l.position.x;
      target.y = l.position.y;
    }
  }
  c1m.arrive(target);
}