title: How to return a string made of the first 2 chars with given conditions
body: <p>I stumbled upon the following problem: </p>
  
  <p>Given a string, return a string made of the first 2 chars (if present), however include first char only if it is 'o' and include the second only if it is 'z', so "ozymandias" yields "oz".</p>
  
  <p>Bellow is my try, but please take in consideration that I am a begginer.</p>
  
  <pre><code>public String startOz(String str) {
   if(str.length()&gt;=2 &amp;&amp; str.substring(0,2)=="oz")
       return "oz";
   if(str.length()&gt;=1 &amp;&amp; str.substring(0,1)=="o")
       return "o";
   if(str.length()&gt;=2 &amp;&amp; str.substring(1,2)=="z")
       return "z";
     return "";
  }   
  </code></pre>
  
  <p>Unfortunately this code doesn't include all the possibilities, maybe is better understandable with an example, if the input would be: startOz("ozk") then instead of "oz" the output will be just a blank space.. Is there a way to salvage my attempt?</p>