Copies the elements from the source list to the destination list. At the end both lists will have the same objects at the same index. If the destination array is larger than the source list, the elements in the destination list with index >= source.size() will be unchanged. @param destinati
(List<? super T> destination,
List<? extends T> source)
| 1589 | * supported. |
| 1590 | */ |
| 1591 | public static <T> void copy(List<? super T> destination, |
| 1592 | List<? extends T> source) { |
| 1593 | if (destination.size() < source.size()) { |
| 1594 | // luni.38=Source size {0} does not fit into destination |
| 1595 | throw new ArrayIndexOutOfBoundsException(Messages.getString("luni.38", source.size())); //$NON-NLS-1$ |
| 1596 | } |
| 1597 | Iterator<? extends T> srcIt = source.iterator(); |
| 1598 | ListIterator<? super T> destIt = destination.listIterator(); |
| 1599 | while (srcIt.hasNext()) { |
| 1600 | try { |
| 1601 | destIt.next(); |
| 1602 | } catch (NoSuchElementException e) { |
| 1603 | // luni.38=Source size {0} does not fit into destination |
| 1604 | throw new ArrayIndexOutOfBoundsException(Messages.getString("luni.38", source.size())); //$NON-NLS-1$ |
| 1605 | } |
| 1606 | destIt.set(srcIt.next()); |
| 1607 | } |
| 1608 | } |
| 1609 | |
| 1610 | /** |
| 1611 | * Returns an {@code Enumeration} on the specified collection. |