I want to check if the value is in a set without looping through it to check if the value is present in the set to improve efficiency. Is that possible?
You should use HashSet as it will use hashing, using a list won't be useful because you probably don't want repeating elements is you are using a set. I think if you want repeating elements then you should use a different DS.
With a HashSet, the contains(obj) will check if obj is in the set in O(1) time.
With a TreeSet, it'll be O(log n) time.
However, if you use a List, then contains() will take O(N) time.