title: move elements around in 2d array
body: <p>I want to move false elements in empty space (just like in Schelling's Model of Segregation).
  This is the array ..(the elements in the array are placed randomly)</p>
  
  <pre><code>'X' 'X' ' ' 'O' 'X' 
  'X' ' ' 'X' ' ' 'O' 
  'X' 'O' ' ' 'O' 'O' 
  ' ' 'O' ' ' ' ' ' ' 
  ' ' ' ' ' ' ' ' ' '     
  </code></pre>
  
  <p>the element at (0,4),(1,2),(2,1),(3,1) are false because it does no have similar elements around it or does not have enough cells around it.  <strong>I want to move those false elements to blank location ' ' in the array</strong> and make those false location blank ' '.  The false element can be moved to any empty location in the array to make it look something like this</p>
  
  <pre><code>'X' 'X' 'X' 'O' ' ' 
  'X' 'X' ' ' 'O' 'O' 
  'X' ' ' 'O' 'O' 'O' 
  ' ' ' ' ' ' ' ' ' ' 
  ' ' ' ' ' ' ' ' ' ' 
  </code></pre>
  
  <p><strong>This is what I get</strong></p>
  
  <pre><code>'X' 'X' 'X' 'O' 'X' 
  'X' 'X' 'X' 'X' 'O' 
  'X' 'O' 'O' 'O' 'O' 
  'O' 'O' 'O' 'O' 'O' 
  '' '' '' '' ''
  </code></pre>
  
  <p>This is my code.</p>
  
  <pre><code>//isArrGood is a method that checks if the element is false or true
  //arr is 2D array that is being passed in the method
  
      char[] falseCell = new char[arr.length * arr[0].length];
  
      for(int row=0; row&lt;arr.length; row++){
          for(int col=0; col&lt;arr[row].length; col++){
              if(!isArrGood(arr,row,col)){
                  falseCell[row] = arr[row][col];
                  arr[row][col] = ' ';
                  }
              }
          }
  
  
      for(int i=0; i&lt;arr.length; i++){
          for(int j=0; j&lt;arr[0].length; j++){
              if(arr[i][j] == ' '){
                  arr[i][j] = falseCell[i];
              }
          }
      }
  </code></pre>