// "Replace with collect" "true" import java.util.*; public class Main { public Set test(String[] array) { int count = 0; Set set = new HashSet<>(); for(String str : array) { if (str != null) { set.add(str); if(++count == 10) break; } } return set; } }