# The type of the expression must be an array type but it resolved to int

**URL:** <https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632>\
**Category:** Coding Questions\
**Created:** [June 2, 2018, 1:14pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632 "2018-06-02T13:14:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeWy](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@PeWy](https://discourse.processing.org/u/PeWy)\
**Post date:** [June 2, 2018, 1:14pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632/1 "2018-06-02T13:14:56Z")

</div>

Hello. I need to convert content of int array to String and put it in to String array.  
I was try to use method “String.valueOf(pozitionX)” , but processing give me message: “The type of the expression must be an array type but it resolved to int”. And underline “pozitionX”. Problem is on line number 190. There is the code:

```auto
int[] souradniceX=new int[5000];
int[] souradniceY=new int[5000];
boolean[] zvednuti=new boolean[5000];
String poziceXStr[]= new String[5000];
String poziceYStr[]= new String[5000];
String vystup;
String indexStr;
String zvednutiStr;

int asd;
int asb;

int indexX=1;
int indexY=1;

int bx=1;
int ax=350;
int poziceX;
int cx=0;
boolean potvrzeniX=false;

int ay=0;
int by=1;
int cy=0;
int poziceY;
boolean potvrzeniY=false;

int minusX;

boolean tlacPrint;
boolean tlacStop;
boolean tlacDelete;

void setup(){
  size(1110,760);
  background(190,190,200);
  maluj();
  for(int hj=0;hj<5000;hj++){
    zvednuti[hj]=true;
  }
}

void draw(){
  kresleni();
  tlacitka();
  if(tlacPrint==true){
    
  }
  if(tlacDelete==true){
    maluj();
 bx=1;
 ax=350;
 cx=0;
 potvrzeniX=false;
 ay=0;
 by=1;
 cy=0;
 potvrzeniY=false;

  }
  delay(10);
      
  if((indexX==4999)||(indexY==4999)){
    for(;;){
      println("plno");
      tlacitka();
      if(tlacPrint=true){
        tisknuti();
      }
    }
  }
  
  
}

void tlacitka(){
  tlacitkoPrint();
  tlacitkoStop();
  tlacitkoDelete();
}

void tlacitkoPrint(){
  if(mouseButton==LEFT){
  if((mouseX>30)&&(mouseX<160)&&(mouseY>30)&&(mouseY<180)){
    tlacPrint=true;
  }
  else{
    tlacPrint=false;
  }
  }
}

void tlacitkoStop(){
  if(mouseButton==LEFT){
  if((mouseX>190)&&(mouseX<320)&&(mouseY>30)&&(mouseY<180)){
    tlacStop=true;
  }
  else{
    tlacStop=false;
  }
}
}

void tlacitkoDelete(){
  if(mouseButton==LEFT){
  if((mouseX>30)&&(mouseX<160)&&(mouseY>210)&&(mouseY<360)){
    tlacDelete=true;
  }
  else{
    tlacDelete=false;
  }
}
}

void kresleni(){
  
  if((mouseX>350)&&(mouseButton==LEFT)){//pokud je tlačíto stisknuto
    
    while(ax<1110){
     if((mouseX>ax)&&(mouseX<ax+20)){//porovnání pozice X s myší
       poziceX=ax;
       if(indexX>1){
       if(souradniceX[indexX-1]==bx){
         break;
      }//souradnice
      else{
       souradniceX[indexX]=bx;
       bx=1;
       indexX++;
       ax=350;
       break;
       }//else
     }//indexX
     else{
       souradniceX[indexX]=bx;
       bx=1;
       indexX++;
       ax=350;
       break; 
     }//else*/
     }//mouseX>ax
     ax=ax+20;
     bx++;
   // }//neí
    }//while
    
    while(ay<760){
      if((mouseY>ay)&&(mouseY<ay+20)){//porovnání pozice Y s myší
      if(indexY>1){
      if(souradniceY[indexY-1]==bx){
        break;
      }//souradnice
      else{
        poziceY=ay;
        souradniceY[indexY]=by;
        by=1;
        indexY++;
        ay=0;
        break;
      }
      }//indexY>1
      else{
        poziceY=ay;
        souradniceY[indexY]=by;
        by=1;
        indexY++;
        ay=0;
        break;
      }//else
      }//mouse>ay
      ay=ay+20;
      by++;
    }//while
    fill(0,255,0);
    //poziceX=poziceX;
    //poziceY=poziceY+10;
    rect(poziceX,poziceY,20,20);
   // poziceX=0;
    //poziceY=0;
    ay=0;
    ax=350;
    
  }//stisk
}//void

void tisknuti(){
  for(int df=0;df<indexX+1;df++){
  poziceXStr[df]=String.valueOf(poziceX[df]);
  }
  
  /*for(int as=0;as<indexX+1;as++){
indexStr="cislo v cyklu";
String zvednutiStr="a";
 asd=indexX[as];
 asb=indexX[as];
 poziceXStr=String.valueOf(asd);
 poziceYStr=String.valueOf(asb);
  }*/
}

void maluj(){
  fill(190,190,200);
  rect(0,0,1110,760);
  fill(0);
  line(349,0,349,760);//oddělující čáry
  line(348,0,348,760);
  line(347,0,347,760);
  
  line(0,500,350,500);//čára pod tlačítky
  
  for(int i=350;i<1110;i++){//čáry na x
    line(i,0,i,760);
    i=i+19;
  }
  for(int j=0;j<760;j++){//čáry na y
    line(350,j,1110,j);
  j=j+19;
  }
  fill(255);
  rect(0,500,347,260);//textové pole dole
  
  stroke(0);
  fill(0,200,0);
  rect(30,30,130,150);//print button
  fill(255,255,102);
  rect(30,210,130,150);//delete button
  fill(200,0,0);
  rect(190,30,130,150);//stop button
  fill(255);
  rect(190,210,130,150);//nepřiřazené tlačítko
  
  fill(200,0,0);
  rect(30,410,42,60);//malá tlačítka
  fill(200,0,0);
  rect(92,410,42,60);
  fill(200,0,0);
  rect(152,410,42,60);
  fill(200,0,0);
  rect(214,410,42,60);
  fill(200,0,0);
  rect(276,410,42,60);
  
}

```

Iam sorry, because name of variables are in another language (Iam from Czech Republic). Please help me.  
And its good to say,this code is program for small drawing cnc machine powered by Arduino.  
Thanks you

---

<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 2, 2018, 1:34pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632/2 "2018-06-02T13:34:18Z")

</div>

[https://Processing.org/reference/strconvert\_.html](https://Processing.org/reference/strconvert_.html)

---

<div class="post-metadata">

**Author:** ![PeWy](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@PeWy](https://discourse.processing.org/u/PeWy)\
**Post date:** [June 2, 2018, 2:27pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632/3 "2018-06-02T14:27:38Z")

</div>

I was try it, but error is still same

---

<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 2, 2018, 2:51pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632/4 "2018-06-02T14:51:40Z")

</div>

Where are you trying to use **str()** at? 😐

---

<div class="post-metadata">

**Author:** ![PeWy](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@PeWy](https://discourse.processing.org/u/PeWy)\
**Post date:** [June 2, 2018, 3:03pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632/5 "2018-06-02T15:03:26Z")

</div>

```auto
void tisknuti(){
  for(int df=0;df<indexX+1;df++){
  poziceXStr[df]=str(poziceX[df]);
  }

```

---

<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 2, 2018, 4:47pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632/6 "2018-06-02T16:47:23Z")

</div>

```auto
void tisknuti() {
  poziceXStr = str(poziceX);
}

```

---

<div class="post-metadata">

**Author:** ![PeWy](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@PeWy](https://discourse.processing.org/u/PeWy)\
**Post date:** [June 2, 2018, 4:52pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632/7 "2018-06-02T16:52:51Z")

</div>

its not working. Error message: "Type mismatch, “java.lang.String” does ot match with “java.lang.String[]”

---

<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 2, 2018, 5:00pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632/8 "2018-06-02T17:00:20Z")

</div>

Variable _poziceX_ isn’t an array of `int` values, but just an `int`.

Either declare it as an array or choose 1 of _poziceXStr[]_'s indices to store its current value there:

```auto
void tisknuti(final int idx) {
  poziceXStr[idx] = str(poziceX);
}

```

---

<div class="post-metadata">

**Author:** ![PeWy](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@PeWy](https://discourse.processing.org/u/PeWy)\
**Post date:** [June 2, 2018, 5:06pm UTC](https://discourse.processing.org/t/the-type-of-the-expression-must-be-an-array-type-but-it-resolved-to-int/632/9 "2018-06-02T17:06:17Z")

</div>

yes, now there is not any error message. When I have time, I will test it, if it is working well.  
Thanks
