I believe this task is looking for something very specific and I cannot figure out what that is (or there is a bug). Has anyone else passed this task? If so, could you give me a little push to help me understand what exactly the 3rd requirement is looking for?
package com.codegym.task.task35.task3506;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
/*
Wildcards
*/
public class Solution {
public static <D> void add(List<D> destinationList, List<? extends D> sourceList) {
ListIterator<? super D> destListIterator = destinationList.listIterator();
ListIterator<? extends D> srcListIterator = sourceList.listIterator();
for (int i = 0; i < sourceList.size(); i++) {
destListIterator.add(srcListIterator.next());
}
}
public static void main(String[] args) {
List<B> destination = new ArrayList<>();
destination.add(new B());
List<C> source = new ArrayList<>();
source.add(new C());
add(destination, source);
System.out.println(destination);
System.out.println(source);
/*
[com.codegym.test.level39.lesson08.task01.Solution$C@203b4f0e, com.codegym.test.level39.lesson08.task01.Solution$B@15c330aa]
[com.codegym.test.level39.lesson08.task01.Solution$C@203b4f0e]
*/
}
static class A {
}
static class B extends A {
}
static class C extends B {
}
}