I want to know the comparison between List and Set in terms of performance,memory allocation and usability.
If i don\'t have any requirement of keeping the uniquenes
Use HashSet if you need to use .contains(T) frequently.
Example:
private static final HashSet KEYWORDS = Stream.of(new String[]{"if", "do", "for", "try", "while", "break", "return"}).collect(Collectors.toCollection(HashSet::new));
public boolean isKeyword(String str) {
return KEYWORDS.contains(str);
}