title: Efficient way to compare version strings in Java
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/198431/how-do-you-compare-two-version-strings-in-java">How do you compare two version Strings in Java?</a>  </p>
  </blockquote>
  
  
  
  <p>I've 2 strings which contains version information as shown below:</p>
  
  <pre><code>str1 = "1.2"
  str2 = "1.1.2"
  </code></pre>
  
  <p>Now, can any one tell me the efficient way to compare these versions inside strings in Java &amp; return 0 , if they're equal, -1, if str1 &lt; str2 &amp; 1 if str1>str2.</p>