title: How can I resolve this error? (This type must be an array type but is resolved to a string)
body: <p>I am trying to practice string manipulation skills and I came up with this as a solution to check a string array for every word that ends in 'y' or 'z' (a word being defined as a string of characters separated by a space) but its wrong obviously. What can I do to resolve this error?</p>
  
  <pre><code>static int wordEndYZ(String str) 
  {
  
      int i, j, counter;
  
      for( i = 0; i &lt; str.length(); i++ ) // search through string array
      {
          j=i;                                // copy position so original position intact
          while ( str[j] == ' ' )             // *First error* space occurs, check last letter
          {
              if ( str[j-1] == 'y' || 'x' )   // 'y' or 'z'? If so counter increments
                  counter += 1;               
          }           
      }
      return counter;
  }
  </code></pre>