Java Utililty Methods HashSet Create

List of utility methods to do HashSet Create

Description

The list of methods to do HashSet Create are organized into topic(s).

Method

intselect(HashSet S)
select
Random R = new Random();
int r = R.nextInt(S.size());
int i = 0;
for (int e : S) {
    i++;
    if (i == r) {
        return e;
return 0;
HashSetstringArrayToHashset(String[] strings)
A function for converting string arrays to HashSets of strings, provided as a convenience for preparing string arrays for TNRS.
HashSet<String> stringSet = new HashSet<String>();
for (int i = 0; i < strings.length; i++) {
    stringSet.add(strings[i]);
return stringSet;
HashSettoHashSet(Object[] array)
to Hash Set
HashSet result = new HashSet();
for (int i = array.length - 1; i >= 0; i--)
    result.add(array[i]);
return result;
SettoHashSet(Set inp)
to Hash Set
Set<T> rslt = new HashSet<>();
rslt.addAll(inp);
return rslt;