// "Replace with toArray" "true" package com.google.common.collect; import java.util.*; class Sets { public static TreeSet newTreeSet() { return new TreeSet(); } } public class Test { public String[] test(List input) { Set set = Sets.newTreeSet(); for(String s : input) { if(s != null) { Collections.addAll(set, s, s+s); } } return set.toArray(new String[0]); } }