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)
======================================================================