N
N
neverbethesameagain2020-06-02 14:58:49
Java
neverbethesameagain, 2020-06-02 14:58:49

How to get (remove) a specific element in a HashSet by index?

import java.util.*;
import java.io.*;


class Ideone
{
  public static void main (String[] args) throws java.lang.Exception
  {
  HashSet<Integer> set = new HashSet<>();
    set.add(1);
    set.add(2);
    set.add(3);
    
  }
}


If there is no set.get(i) in Set , then how to do it ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-06-02
@neverbethesameagain

No way, HashSet is an unordered collection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question