# Problem while I learning Arrray

**URL:** https://discourse.processing.org/t/problem-while-i-learning-arrray/991
**Category:** Coding Questions
**Created:** [June 15, 2018, 2:53pm UTC](https://discourse.processing.org/t/problem-while-i-learning-arrray/991 "2018-06-15T14:53:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![KangYunJae](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kangyunjae/32/456_2.png) [@KangYunJae](https://discourse.processing.org/u/KangYunJae)
#### Post date: [June 15, 2018, 2:53pm UTC](https://discourse.processing.org/t/problem-while-i-learning-arrray/991/1 "2018-06-15T14:53:12Z")

</div>

**This Is Working Version of What I learn.**

```auto
float[] x = new float[5];

void setup() {
  size(1080,720);
  noStroke();
}

void draw() {
  background(0);
  x[0] += 0.5; 
  x[1] += 0.5;
  x[2] += 0.5;
  x[3] += 0.5;
  x[4] += 0.5;
  arc(x[0], 20, 20, 20, 0.52, 5.76);
  arc(x[1], 40, 20, 20, 0.52, 5.76);
  arc(x[2], 60, 20, 20, 0.52, 5.76);
  arc(x[3], 80, 20, 20, 0.52, 5.76);
  arc(x[4], 100, 20, 20, 0.52, 5.76);
}

```

**It’s not working version of What I learn**

```auto
float[] x = {-10,10,35,18,30};
//[{
//NO new float{}
  
void setup() {
  size(1080,720);
  noStroke();
}

void draw() {
  background(0);
  x[-10] += 0.5; //??
  x[10] += 0.5;
  x[35] += 0.5;
  x[18] += 0.5;
  x[30] += 0.5;
  arc(x[-10], 20, 20, 20, 0.52, 5.76); //??
  arc(x[10], 40, 20, 20, 0.52, 5.76);
  arc(x[35], 60, 20, 20, 0.52, 5.76);
  arc(x[18], 80, 20, 20, 0.52, 5.76);
  arc(x[30], 100, 20, 20, 0.52, 5.76);
}

```

I was realize working version of my code doesn’t showing what I want excatly.  
I was excepting bit spread arcs. but, processing shows message that my code have  
problem with [-10]…

How can I fix it??

---

<div class="post-metadata">

### Author: ![cumulus](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cumulus/32/451_2.png) [@cumulus](https://discourse.processing.org/u/cumulus)
#### Post date: [June 15, 2018, 3:25pm UTC](https://discourse.processing.org/t/problem-while-i-learning-arrray/991/2 "2018-06-15T15:25:04Z")

</div>

You are using the values instead of the arrays’ indices 😉

```auto
  x[0] += 0.5; //??
  x[1] += 0.5;
  x[2] += 0.5;
  x[3] += 0.5;
  x[4] += 0.5;
  arc(x[0], 20, 20, 20, 0.52, 5.76); //??
  arc(x[1], 40, 20, 20, 0.52, 5.76);
  arc(x[2], 60, 20, 20, 0.52, 5.76);
  arc(x[3], 80, 20, 20, 0.52, 5.76);
  arc(x[4], 100, 20, 20, 0.52, 5.76);

```

---

<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: [June 15, 2018, 4:46pm UTC](https://discourse.processing.org/t/problem-while-i-learning-arrray/991/3 "2018-06-15T16:46:03Z")

</div>

```auto
static final float SPD = .5;
static final int PACMEN = 5, FPS = 60, DIM = 20;
final float[] x = new float[PACMEN];

void setup() {
  size(1200, 120);
  frameRate(FPS);
  noStroke();
}

void draw() {
  background(0);

  for (int i = 0; i < PACMEN; ++i)
    arc(x[i] += SPD, i*DIM + DIM, DIM, DIM, .52, 5.76);
}

```

---

<div class="post-metadata">

### Author: ![KangYunJae](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kangyunjae/32/456_2.png) [@KangYunJae](https://discourse.processing.org/u/KangYunJae)
#### Post date: [June 16, 2018, 1:48am UTC](https://discourse.processing.org/t/problem-while-i-learning-arrray/991/4 "2018-06-16T01:48:07Z")

</div>

Thanks a lot @cumulus! I didn’t know how easy and simple to solve this!

---

<div class="post-metadata">

### Author: ![KangYunJae](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kangyunjae/32/456_2.png) [@KangYunJae](https://discourse.processing.org/u/KangYunJae)
#### Post date: [June 16, 2018, 1:50am UTC](https://discourse.processing.org/t/problem-while-i-learning-arrray/991/5 "2018-06-16T01:50:11Z")

</div>

Thanks @GotoLoop! this is really amazing too!! thanks!
