Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4095969

java.util.Vector.contains() - wrong explanation in Documentation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.1.4
    • docs
    • 1.2
    • sparc
    • solaris_2.5.1



      Name: diC59631 Date: 12/01/97


      Hi! 8-)

      In http://www.javasoft.com:80/products/jdk/1.1/docs/api/java.util.Vector.html
      written:

      ---

       public final boolean contains(Object elem)

           Tests if the specified object is a component in this vector.

           Parameters:
               elem - an object.
           Returns:
               true if the specified object is a component in this vector; false otherwise.
      ---
      The description of contains() should probably be something similiar to
      the description of indexOf()
      [public final int indexOf(Object elem)

           Searches for the first occurence of the given argument, testing for equality using
           the equals method.]
      becouse contains() is also testing elements by
      calling element's equals() method.

      Example:

      --- test.java ---
      public class test {
       
      public class EqTest {
          public boolean equals(Object obj) {
              return false;
          }
      }
       
      public static void main(String a[]) {
              new test().go();
      }
       
      void go() {
              java.util.Vector testVector = new java.util.Vector();
              EqTest eq = new EqTest();
              testVector.addElement(eq);
              System.out.println(testVector.contains(eq));
      }
      }

      --- end test.java ---

      Running test will tell "false", although
      "eq" IS a component in this Vector!

      ----
       - leon
      (Review ID: 21128)
      ======================================================================

            asommere Alan Sommerer (Inactive)
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: