title: java best practices
body: <p>Need to find out more optimized ways to code in Java.</p>
  
  <p>Here is a very simple sample code </p>
  
  <pre><code>int index1 = line.indexOf(" ", word1.length() + 1);
  if (!line.isEmpty() &amp;&amp; index1 != -1) {
  line = line.substring(word1.length(), index1).trim().toLowerCase();
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>if(!line.isEmpty() &amp;&amp; line.indexOf(" ",word1.length()+1) != -1){
  line = line.substring(word1.length(), index1).trim().toLowerCase();
  }
  </code></pre>
  
  <p>What I noticed is the most of the times you have to decide between better code readability or perhaps more optimized code. Which one is better approach?</p>