# Replace first character of string

**URL:** <https://discourse.processing.org/t/replace-first-character-of-string/27000>\
**Category:** Coding Questions\
**Created:** [January 12, 2021, 8:51pm UTC](https://discourse.processing.org/t/replace-first-character-of-string/27000 "2021-01-12T20:51:17Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![vestergaard12](https://avatars.discourse-cdn.com/v4/letter/v/c67d28/32.png) [@vestergaard12](https://discourse.processing.org/u/vestergaard12)\
**Post date:** [January 19, 2021, 10:56am UTC](https://discourse.processing.org/t/replace-first-character-of-string/27000/22 "2021-01-19T10:56:11Z")

</div>

Thank you very much @CodeMasterX. This helped me a lot.

```auto
String nextWord = words.get((int)random(words.size()));`

```

But sometimes I get a StackOverFlowError at this line. What can I do to fix this?  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/92a790923da28a047ee8631c72edcf314e5af955.png)

---

<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:** [January 19, 2021, 11:01am UTC](https://discourse.processing.org/t/replace-first-character-of-string/27000/23 "2021-01-19T11:01:27Z")

</div>

it is because you called a complex function too many times. I don’t know why, but yeah.

If you have a function like

```auto
void aaa() {
   aaa();
}

```

(a function resulting in an infinite loop)  
It will crash.

[Previous page](https://discourse.processing.org/t/replace-first-character-of-string/27000.md?page=1)
