Compares the specified object to this vector and returns if they are equal. The object must be a List which contains the same objects in the same order. @param object the object to compare with this object @return true if the specified object is equal to this vector, {@co
(Object object)
| 387 | * @see #hashCode |
| 388 | */ |
| 389 | @Override |
| 390 | public synchronized boolean equals(Object object) { |
| 391 | if (this == object) { |
| 392 | return true; |
| 393 | } |
| 394 | if (object instanceof List) { |
| 395 | List<?> list = (List<?>) object; |
| 396 | if (list.size() != elementCount) { |
| 397 | return false; |
| 398 | } |
| 399 | |
| 400 | int index = 0; |
| 401 | Iterator<?> it = list.iterator(); |
| 402 | while (it.hasNext()) { |
| 403 | Object e1 = elementData[index++], e2 = it.next(); |
| 404 | if (!(e1 == null ? e2 == null : e1.equals(e2))) { |
| 405 | return false; |
| 406 | } |
| 407 | } |
| 408 | return true; |
| 409 | } |
| 410 | return false; |
| 411 | } |
| 412 | |
| 413 | /** |
| 414 | * Returns the first element in this vector. |