# Calling a String Array to name a new integer array

**URL:** https://discourse.processing.org/t/calling-a-string-array-to-name-a-new-integer-array/13080
**Category:** Beginners
**Created:** [July 31, 2019, 2:55am UTC](https://discourse.processing.org/t/calling-a-string-array-to-name-a-new-integer-array/13080 "2019-07-31T02:55:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mpn702](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@mpn702](https://discourse.processing.org/u/mpn702)
#### Post date: [July 31, 2019, 2:55am UTC](https://discourse.processing.org/t/calling-a-string-array-to-name-a-new-integer-array/13080/1 "2019-07-31T02:55:35Z")

</div>

I’m trying to write a loop that will generate a collection of new integer arrays based on the elements in a string ArrayList, but unfortunately Processing is having trouble calling the ArrayList in the definition of each array.

The problem seems to be that Processing doesn’t know I’m just trying to call the element in the ArrayList to name another Array.

> StringList characs;  
> characs = new StringList();  
> characs.append(“Harry”);  
> characs.append(“Hermione”);  
> characs.append(“Ron”);  
> characs.append(“Hagrid”);  
> characs.append(“Dumbledore”);  
> characs.append(“Voldemort”);  
> characs.append(“Draco”);  
> characs.append(“Longbottom”);  
> characs.append(“McGonagall”);  
> characs.append(“Snape”);  
> characs.append(“Quirrell”);
> 
> String item;
> 
> for (int a = 0; a \<= characs.size(); a++) {
> 
> ```
> item = (characs.get(a));
> 
> ```

```
   item2 = (characs.get(a+1));

```

> ```
> int[] string(item+'_ind') = new int[hp.length]; // Where string(item+'_var') would convert to something like 'Harry_ind' and a new integer array would be created.
> 
> ```

```
     int[] string(item+'_'+item2+'_ind') = new int[hp.length]; // Where string(item+'_'+item2+'_ind') would convert to something like 'Harry_Hermione_ind' and a new integer array would be created.

```

> }

And, yes! I am trying to identify every time the different characters are mentioned in Harry Potter!

Much thanks for your help.

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [August 1, 2019, 9:01am UTC](https://discourse.processing.org/t/calling-a-string-array-to-name-a-new-integer-array/13080/2 "2019-08-01T09:01:38Z")

</div>

That is not ging to work in Processing Java mode since variable names must be declared at compile time and not runtime.  
Are you simply trying to count the number of times the word appears in text?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [August 1, 2019, 9:06am UTC](https://discourse.processing.org/t/calling-a-string-array-to-name-a-new-integer-array/13080/3 "2019-08-01T09:06:00Z")

</div>

Sounds like a Hashmap topic

---

<div class="post-metadata">

### Author: ![rapatski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rapatski/32/5164_2.png) [@rapatski](https://discourse.processing.org/u/rapatski)
#### Post date: [August 1, 2019, 10:30am UTC](https://discourse.processing.org/t/calling-a-string-array-to-name-a-new-integer-array/13080/4 "2019-08-01T10:30:32Z")

</div>

What Chrisir is saying: use a HashMap to store your integer values under String keys:

[https://processing.org/reference/HashMap.html](https://processing.org/reference/HashMap.html)

---

<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 1, 2019, 2:25pm UTC](https://discourse.processing.org/t/calling-a-string-array-to-name-a-new-integer-array/13080/5 "2019-08-01T14:25:31Z")

</div>

Or an IntDict: [Processing.org/reference/IntDict.html](http://Processing.org/reference/IntDict.html)
