title: Return true if string cointains "xyz" not preceeded by a period?
body: <p>I'm trying to solve this CodingBat problem: </p>
  
  <blockquote>
    <p>Return true if the given string contains an appearance of "xyz" where the xyz is not directly preceeded by a period (.). So "xxyz" counts but "x.xyz" does not. </p>
  </blockquote>
  
  <pre><code>xyzThere("abcxyz") → true
  xyzThere("abc.xyz") → false
  xyzThere("xyz.abc") → true
  </code></pre>
  
  <p>My attempt:</p>
  
  <pre><code>public boolean xyzThere(String str) {
    boolean res = false;
  
    if(str.contains(".xyz") == false &amp;&amp; str.contains("xyz")){
      res = true;
    }
  
    return res;
  
  }
  </code></pre>
  
  <p>The problem is that is passes all the tests except the one below because it contains two instances of xyz:</p>
  
  <pre><code>xyzThere("abc.xyzxyz")
  </code></pre>
  
  <p>How can I make it pass all tests?</p>