Object.equals is not well fitted for 'null' comparison

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P3
    • None
    • Affects Version/s: 1.3.1
    • Component/s: core-libs
    • generic
    • generic



      Name: nt126004 Date: 10/29/2001


      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)


      Object.equals is not easy to use when you compare two
      object references that can be null.
      I'd rather have a
      static boolean equals(Object o1, Object o2)
      {
         if (o1 == null) {
             if (o2 == null) {
                 return true;
             }
             return o2.equals(o1);
         }
         return o1.equals(o2);
      }
      in the Object class.
      (Review ID: 134567)
      ======================================================================

            Assignee:
            Iris Clark
            Reporter:
            Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: