title: Check For Leading/Trailing Whitespaces
body: <p>I'm trying to write a function that checks for leading and trailing whitespaces. It shouldn't remove them, just check to see if they exist. I wrote this: </p>
  
  <pre><code>  public static String checkWhitespace(String str)
    {
        if(str.charAt(0) == ' ' || str.charAt(str.length()-1) == ' ');
              return "invalid";
    } 
  </code></pre>
  
  <p>But it's catching everything. I tried using <code>"\\s+"</code> as the key but it's a string and it's only letting me check for chars. Any help would be awesome!</p>