# String Array {}

**URL:** <https://discourse.processing.org/t/string-array/23082>\
**Category:** Beginners\
**Created:** [August 6, 2020, 2:33pm UTC](https://discourse.processing.org/t/string-array/23082 "2020-08-06T14:33:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [August 6, 2020, 2:33pm UTC](https://discourse.processing.org/t/string-array/23082/1 "2020-08-06T14:33:05Z")

</div>

can i re-declare the variables in curly braces after declaring the string array?

/  
String [] test = new String [500];

void setup(){}

void draw(){  
test [] = {“shshsj”, “sjjsjsjs”, “2+288383”};  
}  
\</

this does not work.  
How can I do it more correctly. Through square [] brackets I can, but it doesn’t fit right now. I need {}.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [August 6, 2020, 2:39pm UTC](https://discourse.processing.org/t/string-array/23082/2 "2020-08-06T14:39:33Z")

</div>

Curly brackets are used to initialise the array,

So

```auto
String [] test = {“shshsj”, “sjjsjsjs”, “2+288383”};

```

This means the array is now of size 3, and cannot be changed.

The values can however ie

```auto
test[0] = "string";

```

Or you can do

```auto
String [] test = new String [500];

Then

test[0] = "string";
test[1] = "string";

And so on...

```

If you are unsure of the size required then use lists or arraylists

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [August 6, 2020, 2:56pm UTC](https://discourse.processing.org/t/string-array/23082/4 "2020-08-06T14:56:04Z")

</div>

Can’t I reinitialize the array after a certain time through curly braces?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [August 6, 2020, 3:00pm UTC](https://discourse.processing.org/t/string-array/23082/5 "2020-08-06T15:00:05Z")

</div>

Yes but then you will lose all previously stored values

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [August 6, 2020, 3:01pm UTC](https://discourse.processing.org/t/string-array/23082/6 "2020-08-06T15:01:13Z")

</div>

I agree. please help me figure out how to do this.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [August 6, 2020, 3:03pm UTC](https://discourse.processing.org/t/string-array/23082/7 "2020-08-06T15:03:03Z")

</div>

Sorry not possible once initialised with curlys

Normally I only use curlys if I already know what I want in the array

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [August 6, 2020, 3:05pm UTC](https://discourse.processing.org/t/string-array/23082/8 "2020-08-06T15:05:56Z")

</div>

In any case, thanks for being able to sort this out. now I know that it will not be possible to use {}.

\<3

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [August 6, 2020, 3:07pm UTC](https://discourse.processing.org/t/string-array/23082/9 "2020-08-06T15:07:06Z")

</div>

What is it you’re trying to achieve if you describe your problem I can probably give you a more appropriate solution.

---

<div class="post-metadata">

**Author:** ![NoName](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@NoName](https://discourse.processing.org/u/NoName)\
**Post date:** [August 6, 2020, 3:07pm UTC](https://discourse.processing.org/t/string-array/23082/10 "2020-08-06T15:07:51Z")

</div>

It doesn’t matter anymore, curly braces were needed only for convenience, square brackets would also work. Thank you for your help. Hugged.

---

<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:** [August 6, 2020, 3:13pm UTC](https://discourse.processing.org/t/string-array/23082/11 "2020-08-06T15:13:45Z")

</div>

> [@Keyword "new" and arrays - clarification](https://discourse.processing.org/t/keyword-new-and-arrays-clarification/22598):
>
> Hello Forum, This question is about explaining arrays simply to beginners…please correct or clarify, thank you slight_smile When an array is declared and initialized at the same time like this: int mySet[] = {15,75,123,105,165,290}; then key word “new” is unnecessary. However, when an array is declared but not initialized yet then the key word “new” is required like this: int mySet[] = new int[6]; So, is it fair to say, "the keyword “new” is only required when using an array[] that is …
