<p>In the same spirit of other platforms, it seemed logical to follow up with this question: What are common non-obvious mistakes in Java? Things that seem like they ought to work, but don't.</p>

<p>I won't give guidelines as to how to structure answers, or what's "too easy" to be considered a gotcha, since that's what the voting is for.</p>

<p>See also:</p>

<ul>
<li><a href="https://stackoverflow.com/questions/166653/perl-common-gotchas">Perl - Common gotchas</a></li>
<li><a href="https://stackoverflow.com/questions/66117/aspnet-common-gotchas">.NET - Common gotchas</a></li>
</ul>

Going first, here's one I caught today. It had to do with
```
Long
```
/
```
long
```
confusion.
```
```
public void foo(Object obj) {
    if (grass.isGreen()) {
        Long id = grass.getId();
        foo(id);
    }
}
private void foo(long id) {
    Lawn lawn = bar.getLawn(id);
    if (lawn == null) {
        throw new IllegalStateException("grass should be associated with a lawn");
    }   
}
```
```
Obviously, the names have been changed to protect the innocent :)