title: Freeman Chain Code in Java
body: <p>Okay, hopefully this makes more sense. I have an array hard coded with only 1s and 0s. I am trying to write a function that reads each element to see if it is a 0 or 1. If it is a 1, it will execute another function and then change that 1 to a 0 so that it is not read again. I have it printing simply as a placeholder for the other function I will be implementing later. I'm having trouble getting the findfirst1 function to check every element in the array. I have tried putting the incrementors for i and k in different places within the flow of the code but nothing I have tried gets me the correct output.</p>
  
  <pre><code>public static void main(String[] args)
  {
      int[][] testarray = {{1,0,0,0,0,0,0,1},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},
              {0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{1,0,0,0,0,0,0,1}};
  
      findfirst1(testarray);
  }
  
  public static void findfirst1(int[][] array1) 
  {
      int value = 0;
      for(int i = 0; i &lt; 6;i++)
      {
          for(int k = 0; k &lt; 7;k++)
          {
              value = array1[i][k];
              if(value == 1)
              {
                  System.out.println(value);
                  array1[i][k] = 0;
              }
              else
              {
                  System.out.println(value);
              }
          }
      }
  
  }
  </code></pre>