title: How to check for an Empty String
body: <p>I am trying to assign a default value to variable if the variable holds an empty string. I used the following codes but they are not working out:</p>
  
  <pre><code>if (d.lat.trim().isEmpty())
     latt = 9.0819990;
  else {
     latt = Double.valueOf(d.lat.trim()).doubleValue();
  }
  </code></pre>
  
  <p><strong>The above code results in an error:</strong> </p>
  
  <pre><code>cannot find symbol
  symbol  : method isEmpty()
  location: class java.lang.String
  </code></pre>
  
  <p>then I used </p>
  
  <pre><code>if (" ".equals(d.lat.trim()))
     latt = 9.0819990;
  else {
     latt = Double.valueOf(d.lat.trim()).doubleValue();
  }
  </code></pre>
  
  <p>The code above jumps the <code>if</code> section and tries to convert the empty String into double thereby throwing error about empty string.</p>
  
  <p>SO, what am I doing wrong?</p>