title: Return the string that is between the first and last appearance of "bread" in the given string
body: <p>This question is from coding bat and might have been asked before. Please review the code.</p>
  
  <p>A sandwich is two pieces of bread with something in between. Return the string that is between the first and last appearance of "bread" in the given string, or return the empty string "" if there are not two pieces of bread. </p>
  
  <pre><code>getSandwich("breadjambread") → "jam"
  getSandwich("xxbreadjambreadyy") → "jam"
  getSandwich("xxbreadyy") → ""
  </code></pre>
  
  <p><strong>My code is</strong></p>
  
  <pre><code>public static String getSandwich(String str) {
          int ind = str.indexOf("bread");
          int laind = str.lastIndexOf("bread");
          if(!(laind == -1 ))return (str.substring(ind+5,laind)) ;
          return "";
      }
  </code></pre>
  
  <p>And I am getting </p>
  
  <pre><code>Exception:java.lang.StringIndexOutOfBoundsException: String index out of range: -5 (line number:4)
  </code></pre>
  
  <p>for this input <code>getSandwich("xxbreadyy")</code></p>