Compares the specified object to this list and return true if they are equal. Two lists are equal when they both contain the same objects in the same order. @param object the object to compare to this object. @return true if the specified object is equal to this list, {@c
(Object object)
| 477 | * @see #hashCode |
| 478 | */ |
| 479 | @Override |
| 480 | public boolean equals(Object object) { |
| 481 | if (this == object) { |
| 482 | return true; |
| 483 | } |
| 484 | if (object instanceof List) { |
| 485 | List<?> list = (List<?>) object; |
| 486 | if (list.size() != size()) { |
| 487 | return false; |
| 488 | } |
| 489 | |
| 490 | Iterator<?> it1 = iterator(), it2 = list.iterator(); |
| 491 | while (it1.hasNext()) { |
| 492 | Object e1 = it1.next(), e2 = it2.next(); |
| 493 | if (!(e1 == null ? e2 == null : e1.equals(e2))) { |
| 494 | return false; |
| 495 | } |
| 496 | } |
| 497 | return true; |
| 498 | } |
| 499 | return false; |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * Returns the element at the specified location in this list. |