title: How to check if a text contains an element of an ArrayList
body: <p>I have a text and an array list. I would like to check if my text contains any element in the ArrayList, and if he does find it, to replace the space between two words with <code>"%"</code>.
  Here's my code : </p>
  
  <pre><code>public static boolean stringContainsItemFromList(String text, ArrayList&lt;String&gt; list)
  {
      for (String i: list)
      {
          if (text.contains(list[i]))
          {
              text.replaceAll(" ", "%");
  
              System.out.println("done");
              return true;
          }
      }
      return false;
  }
  </code></pre>
  
  <p>It gives me this error: <code>string cannot be converted to int</code> for the line <code>if (text.contains(list[i]))</code>. Any idea how else can I proceed? </p>