title: Compare two objects with a check for null
body: <p>Is there a method in the JDK that compares two objects for equality, accounting for nulls?  Something like this:</p>
  
  <pre><code>public static boolean equals(Object o1, Object o2)
  {
      if (o1 == null)
      {
          return o2 == null; // Two nulls are considered equal
      }
      else if (o2 == null)
      {
          return false;
      }
  
      return o1.equals(o2);
  }
  </code></pre>
  
  <p>It seems silly to write this method myself since I would think that it has to exist already somewhere.</p>