I have a HashSet that I would like to iterate through a for loop and display its contents but I don't know how to make it work. I can't seem to find a way to access an element of a certain index(i) of a HashSet. Is there a way to do this?
I have the following (non-compiling) code as my basis of what I want to achieve:
public void postNumbers(HashSet<String> uniqueNumbers)
{
for (int i = 0; i < uniqueNumbers.size(); i++)
{
System.out.println(uniqueNumbers(i));
}
}
I'd like to replace the System.out.println portion of the code (specifically uniqueNumbers(i)) but I don't know how to approach it