I would like to implement a method isInBlackList(String element), which return true, if element is founded in the blacklist. I have the following code:
public boolean isInBlackList(String element) {
Set<String> blackList = new HashSet<String>();
blackList.add("element1");
blackList.add("element2");
...
.....
blackList.add("element20");
return blackList.contains(element);
}
What is bothering me is that I have to write add() method 20 times. Any better idea? it does not have to be implemented with Set.