# Bug with int\[\]={};

**URL:** <https://discourse.processing.org/t/bug-with-int/26135>\
**Category:** Beginners\
**Created:** [December 11, 2020, 12:22pm UTC](https://discourse.processing.org/t/bug-with-int/26135 "2020-12-11T12:22:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 11, 2020, 12:22pm UTC](https://discourse.processing.org/t/bug-with-int/26135/1 "2020-12-11T12:22:14Z")

</div>

Here is a program I wrote for MASTERMIND game. When I was trying a way to get the correct placing & correct numbers.

Here is the code which always returns OutOfBounds exception

```auto
//mastermind
int code[] = {0, 3, 1, 2};
int attempt[] = {0, 0, 1, 0};

void setup() {
  size(600,600);
  
  printArray(code);
  printArray(attempt);
  println(code.length,attempt.length);
}

void draw() {
  background(0);
  check();
}

void check() {
  //checking the right positions
  boolean cc[] = new boolean[code.length+1];
  int ccNum = 0;
  for (int i = 0; i < code.length; i++) if (code[i] == attempt[i]){
    cc[i] = true;
    ccNum++;
  }
  int cNum = 0;
  boolean c[] = new boolean[code.length+1];
  println(ccNum);
  
  for(int i = 0; i < attempt.length; i++) {
    
    for(int j = 0; j < code.length; i++) {
      if( attempt[i] == code[j]) {
        cNum++;
      }
    }
    
    
  }
  println(cNum);
}

```

---

<div class="post-metadata">

**Author:** ![MiguelSanches](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/miguelsanches/32/11172_2.png) [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Post date:** [December 11, 2020, 12:40pm UTC](https://discourse.processing.org/t/bug-with-int/26135/2 "2020-12-11T12:40:29Z")

</div>

Hi @CodeMasterX,

I guess the error is here

```auto
for(int j = 0; j < code.length; i++) {

```

it should be j++ instead

Best regards

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 11, 2020, 3:45pm UTC](https://discourse.processing.org/t/bug-with-int/26135/3 "2020-12-11T15:45:25Z")

</div>

turns out I am just an idiot : P
