# Save multiple Letters

**URL:** https://discourse.processing.org/t/save-multiple-letters/6857
**Category:** Coding Questions
**Tags:** homework
**Created:** [December 23, 2018, 7:05pm UTC](https://discourse.processing.org/t/save-multiple-letters/6857 "2018-12-23T19:05:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tigger97](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@tigger97](https://discourse.processing.org/u/tigger97)
#### Post date: [December 23, 2018, 7:05pm UTC](https://discourse.processing.org/t/save-multiple-letters/6857/1 "2018-12-23T19:05:04Z")

</div>

Hey I’m new,

Our teacher askes us to develope a learning programm for the scrabble game. Basically you get 9 letter from which you can wright a word, that word is then checkedm to see if it is in the Library.

I can already test if a word is valid in the static mode, but I’m at a loss in the active mode. Is there any way to save multiple pressed kesy to a String or Array? My head’s been spinng for the last couple days.

Thanks in advance for any hints 🙂

---

<div class="post-metadata">

### Author: ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)
#### Post date: [December 23, 2018, 8:57pm UTC](https://discourse.processing.org/t/save-multiple-letters/6857/2 "2018-12-23T20:57:29Z")

</div>

Storing states for all keys with a dynamically increasing data set can be pretty tricky. One thing I once did is to use a `Table`, add new columns for previously unknown keys using `Keys.addColumn(key);`, and store either 0 or 1 for each key using `Keys.setInt(0,key,1);` or `Keys.setInt(0,key,0);` inside of `keyPressed()` and `keyReleased()` respectively.

However, in your case, I think the easiest way would be to first store your 9 letters in a `char[]` array, and then make a button for each one of them that you can press only once to add a letter at the end of a `String` that is your result - with a “Reset” button that resets all buttons and that `String`, and a “Check” button that checks if the word is in there or not.  
For simplicity, I suggest making a second `boolean[]` array to store states of all buttons. However, if you are familiar with classes, you might as well make a class for one letter that contains the letter itself and its button’s state.

---

<div class="post-metadata">

### Author: ![tigger97](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@tigger97](https://discourse.processing.org/u/tigger97)
#### Post date: [December 26, 2018, 4:17pm UTC](https://discourse.processing.org/t/save-multiple-letters/6857/3 "2018-12-26T16:17:15Z")

</div>

Thanks for the tip, it inspired a solution.  
I now saved them in a arrayList, not the most elegent way but it works

Now i just have to get rid ob a nullpointer exception and im good to go…
