title: How to optimize do-while loops?
body: <p>I want to execute a loop as long as a certain condition applies. At the end, I want to return the value that was last being found inside the loop.</p>
  
  <p>Non-realworld example:</p>
  
  <pre><code>teststring = "        abcde";
  
  String letter = null;
  do {
      letter = reader.read(); //reads the teststring char by char
  } while (letter.equals(" "));
  return letter; //return "a"
  </code></pre>
  
  <p>Could this be optimized from the coding point of view, eg transform it from a do-while loop to just a while-loop?</p>