Java-- How can I compare 1 array with 1 string?
<p>Ok so I have this peace of code</p>

<p>and inside the if there is this while</p>

<pre><code>           while (true) {

                  if (stringarray[1][a].equals(string2)) {
                     STUFF


                              }
       a++
</code></pre>

<p>the problem is that the (stringarray[1][a].equals(string2)) doesnt work, and I dont know why, or how can I solve it. It works when they are integers, or doubles since I can do arraystuff[0][a]==variable but it doesnt work for strings, what I am doing wrong?. Thanks for your help</p>

<p>Edit: Ok so this is the original (yep the array has 117 different values)
The array (a String defined array (String stringarray [][] = new String [2][117])
a (Integer, starting with 0)String string = new String ("")String string2 = new String ("")</p>

<pre><code>          string = stdIn.readLine();

           while (true) {
                  if (stringarray[0][a].equals(string)) {
                      break;
                    }
                    a++;
                    if (a == 118) {
                        break;
                   }
           }
      }
</code></pre>

<p>If I were to put a System.out.println(a)
a would be 118 even when the text in "string" is correct and It should had stop long before</p>

<p>yet if what the while/if is a numerical value (example 2) the code works and a display the number</p>

<pre><code>           while (true) {
                  if (intarray[0][a]==(randominteger)) {
                      break;
                    }
                    a++;
                    if (a == 118) {
                        break;
                   }
           }
      }
</code></pre>

<p>Then a would be the number I was searching for. 
For example if in the first code I enter the text hi, and the text hi is in number [0][15] then a would be 15, but it doesnt happen, in code 2 if I enter 482 and the number is in [0][34627] then a is really 34627. Hope this help</p>
