# How to return a PVector array?

**URL:** <https://discourse.processing.org/t/how-to-return-a-pvector-array/15340>\
**Category:** Beginners\
**Created:** [November 8, 2019, 5:02pm UTC](https://discourse.processing.org/t/how-to-return-a-pvector-array/15340 "2019-11-08T17:02:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Djharr](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Djharr](https://discourse.processing.org/u/Djharr)\
**Post date:** [November 8, 2019, 5:02pm UTC](https://discourse.processing.org/t/how-to-return-a-pvector-array/15340/1 "2019-11-08T17:02:00Z")

</div>

HI,  
wondering how i’m meant to return a PVector array;

```auto
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 🙂

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [November 8, 2019, 5:07pm UTC](https://discourse.processing.org/t/how-to-return-a-pvector-array/15340/2 "2019-11-08T17:07:19Z")

</div>

> [@Djharr](#):
>
> `public PVector VECTORS(){`

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

```

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [November 8, 2019, 7:31pm UTC](https://discourse.processing.org/t/how-to-return-a-pvector-array/15340/3 "2019-11-08T19:31:51Z")

</div>

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 😉
