String[] (String[] args) { List<String> list = new ArrayList<>(); for(String s : ar<caret>gs) { if(!s.isEmpty()) list.add(s); } Set<String> set = new TreeSet<>(list); return set.toArray(new String[0]); }