title: How do we compare String Array value to a String? (Java)
body: <p>I was wondering if I could compare the String Array value to a String, for eg; I have a String array which has 5 values on it. <code>String [] sampleArray = {"a","b","a","b","a"}</code> and I want to know which index value has <code>a</code> or <code>b</code>. I thought of an idea but it didn't work.</p>
  
  <pre><code>String[] sampleArray = {"a","b","a","b","a"};
  String value;
  for (int i=0; i &lt;= sampleArray.length; i++){
    if ( sampleArray[i].equals("a") ) {
      value = "apple";
    } else {
      value = "ball";
    }
    System.out.println(value);
  }
  </code></pre>
  
  <p>Basically if the <code>index 0</code> is <code>a</code> then it should print "Apple" and if it's <code>b</code> it should print "ball" and so on. Is there any idea to compare values or string array to a string? </p>