# Setting an Array\[\] as function parameter

**URL:** <https://discourse.processing.org/t/setting-an-array-as-function-parameter/26429>\
**Category:** Beginners\
**Created:** [December 21, 2020, 8:26pm UTC](https://discourse.processing.org/t/setting-an-array-as-function-parameter/26429 "2020-12-21T20:26:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 21, 2020, 8:26pm UTC](https://discourse.processing.org/t/setting-an-array-as-function-parameter/26429/1 "2020-12-21T20:26:11Z")

</div>

Hi!  
I made a quiz program where you have to create a `String q[] = {"what is the first letter?","a","b","c"};` and use this in `addQuestion(q,2);`

is it possible to use something like `addQuestion( {"what is the first letter?", "a", "b", "c"},4);`?

If so, how?

---

<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:** [December 22, 2020, 8:07am UTC](https://discourse.processing.org/t/setting-an-array-as-function-parameter/26429/2 "2020-12-22T08:07:17Z")

</div>

> [@CodeMasterX](#):
>
> `addQuestion({ "What is the first letter?", "a", "b", "c" }, 4);`

`addQuestion(new String[] { "What is the first letter?", "a", "b", "c" }, 4);`

---

<div class="post-metadata">

**Author:** ![cansik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cansik/32/8815_2.png) [@cansik](https://discourse.processing.org/u/cansik)\
**Post date:** [December 22, 2020, 12:45pm UTC](https://discourse.processing.org/t/setting-an-array-as-function-parameter/26429/3 "2020-12-22T12:45:48Z")

</div>

I would recommend to use variable arguments for the method you call:

```auto
void addQuestion(int number, String ... parts) {
  ...
}

```

This allows you to either throw in an array, or just strings:

```auto
addQuetion(3, "Really?", "Yes", "No");

```
