Sobes.tech
Intern — Middle

Creating a copy of a string collection

livecode

Task condition

It is necessary to transfer all elements from the original collection Collection<String> to a new collection copied, while the specific implementation type (ArrayList, HashSet, etc.) is unknown to us.

import java.util.Collection;

public class JetbulbInterview {
    public static void main(String[] args) {
        Collection<String> elems = new ArrayList<>();
        elems.add("Hello");
        elems.add("World");
        elems.add("!");

        Collection<String> copied = 
    }
}