title: Why does my code not work when a character is in the second row of the array?
body: <p>I have some code with a method that is trying to return the opposing character label of a 2d array's position.</p>
  
  <p>Let's suppose the array and it's labels for each position are like below:</p>
  
  <pre><code>{{3,3,3,3}, {3,3,3,3}}
    a,b,c,d    e,f,g,h
  </code></pre>
  
  <p>If b is entered, f is returned. I have it working right if a, b, c, or d is entered, but it doesn't work right if e, f, g, or h is entered and I can't figure out why.</p>
  
  <pre><code>public class ByteTest {
  
      public static void main(String[] args) {
          int[][] testArray = {{3,3,3,3}, {3,3,3,3}};
          //                    a b c d    e f g h
          char slectdPit = 'e';
          int total = (int)slectdPit;
          int total97 = total - 97;
          System.out.println(myGetOpposingPit(slectdPit, testArray));
      }
  
      public static char myGetOpposingPit(char b, int[][] ints) {
          char retChar = 'z';
          int retVal = 0;
          int charPosi = 0;
          int total97 = 0;
          for (int i = 0; i &lt; 2; i++) {
              for (int j = 0; j &lt; ints[0].length; j++) {
                  charPosi = (int)b;
                  total97 = charPosi - 97;
                  if (total97 &lt;= ints[0].length) {
                      if (total97 == j) {
                          retVal = (charPosi + ints[0].length);
                          retChar = (char)retVal;
                      }
                  }
  
                  else if (total97 &gt; ints[0].length) {
                      if (total97 == (j + (ints[0].length))) {
                          retVal = (charPosi - ints[0].length);
                          retChar = (char)retVal;
                      }
                  }
              }
          }
          return retChar;
      }
  
  }
  </code></pre>
  
  <p>I've made an if statement </p>
  
  <pre><code> else if (total97 &gt; ints[0].length) {
                  if (total97 == (j + (ints[0].length))) {
                      retVal = (charPosi - ints[0].length);
                      retChar = (char)retVal;
                  }
  </code></pre>
  
  <p>That's supposed to get find labels that are in the second row of the array, and assign returnedChar with <code>characterPosition</code> - array row length, so if the character ran through <code>myGetOpposingPit</code> is g, it'd be <code>charPosi (103) minus ints[0].length (4), equaling 99</code>, which gets <code>ascii</code> converted into 'c'.</p>
  
  <p>Doesn't work though, <code>z</code> gets returned. So one of my if statements isn't running or something.</p>