0

How can I access a specific element in a Set? For example, in a Vector I can access an element using vector.elementAt(i), but it doesn't work for a Set.

Adelin Rau
  • 11
  • 1
  • 3
    There is no elements order in ```Set``` structure. Therefore, you cannot get it like in ```Vector```. – Marcin Rzepecki Oct 28 '20 at 16:31
  • You can try to use ordered set implementation like ```TreeSet```, but I recommend you to consider changing structure for that task to some natively ordered, like ```List```. https://docs.oracle.com/javase/7/docs/api/java/util/TreeSet.htm – Marcin Rzepecki Oct 28 '20 at 16:37

0 Answers0