# I'm new and I need help with arrays

**URL:** <https://discourse.processing.org/t/im-new-and-i-need-help-with-arrays/37281>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [June 2, 2022, 4:01pm UTC](https://discourse.processing.org/t/im-new-and-i-need-help-with-arrays/37281 "2022-06-02T16:01:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosepAlqueza](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josepalqueza/32/16390_2.png) [@JosepAlqueza](https://discourse.processing.org/u/JosepAlqueza)\
**Post date:** [June 2, 2022, 4:01pm UTC](https://discourse.processing.org/t/im-new-and-i-need-help-with-arrays/37281/1 "2022-06-02T16:01:06Z")

</div>

Hello everyone!

I’m new to the world of programming and need help with arrays. I have to do a practice where I have a multidimensional array (attached image) where the first column appears the position X and the second position Y of a String that I have where the name of 18 city appears.

I have to place on an image the name of each city. My doubt is that I do not know how I can do so that with the text function insert a variable that corresponds to the X or Y position of the array.

I would really appreciate any kind of help

![Captura de pantalla 2022-06-02 a las 17.58.28](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/d/a/daa1896f869ec5180fb396011cd51b3f8d51ad47.png)

---

<div class="post-metadata">

**Author:** ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Post date:** [June 2, 2022, 4:19pm UTC](https://discourse.processing.org/t/im-new-and-i-need-help-with-arrays/37281/2 "2022-06-02T16:19:38Z")

</div>

You could save the Strings in an seperate array. And when iterating over the first list can access the corrosponding member in the String array and use that as text.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [June 2, 2022, 4:26pm UTC](https://discourse.processing.org/t/im-new-and-i-need-help-with-arrays/37281/3 "2022-06-02T16:26:54Z")

</div>

Hi @JosepAlqueza ,

You can access the array this way.  
What about the 3rd column? Is this a id for the cityname !?

```auto
void setup() {
   size(1500,1000);
}

void draw() {
    background(0);
    fill(255);
    for(float[] city : cities) {
       float x = city[0];
       float y = city[1];
       float id = city[2]; // what is that number? Id of another array with the citynames ?
       String cityname = "dummy"; // ie citynames[floor(id)] !?
       text(cityname,x,y);
    }
}

```

If it is 3rd not the id you can extend it by one column and give the entries a number from 0 to rows-1 and make a string array … ie

```auto
float[][] cities = {
{232,654,2344555,0},
{554,755,2344555,1}
};

String[] citynames = {
      "cityname1",
      "cityname2"
       // and so on
};

// Then in the above code
// ....
       float id = city[3]; 
       String cityname = citynames[floor(id)];
//....

```

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![JosepAlqueza](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josepalqueza/32/16390_2.png) [@JosepAlqueza](https://discourse.processing.org/u/JosepAlqueza)\
**Post date:** [June 2, 2022, 4:40pm UTC](https://discourse.processing.org/t/im-new-and-i-need-help-with-arrays/37281/4 "2022-06-02T16:40:41Z")

</div>

Hy mnse,

Thanks for your help. It helped me solve my problem.

The third column is the population of every different city
