I have a program that looks like the following attached image, and I'm wondering why the initial array "words" needs to be converted into a list before it can be stored in a HashSet. Can I store it directly in a HashSet? Thank you in advance!
public class Starter {
public int begins(String[] words, String first) {
HashSet<String> hset = new HashSet(Arrays.asList(words));
char firstChar = first.charAt(0);
int total = 0;
for (String i : hset) {
if (firstChar == (i.charAt(0))) {
total += 1;
}
}
return total;
}
}