How to return a PVector array?

HI,
wondering how iā€™m meant to return a PVector array;

public PVector VECTORS(){
  PVector[] v = new PVector[1000];
  for(int i =0; i<v.length; i++){
  v[i] = new PVector(random(width), random(height));
}
return v;
}

this gives me the error "cannot convert PVector[] to PVector.

unsure what im doing wrong.

any help is much appreciated.
Thanks in advance :slight_smile:

1 Like
PVector[] vectors(int len) {
  final PVector[] vecs = new PVector[len];
  return vecs;
}
1 Like

You are trying to return a PVector[] using a method that returns a PVector (not array).

You just need to add [] after the first time you wrote PVector.

Also, please Format your Code the next time :wink:

2 Likes