HashSet,锋芒毕露,我们最常用到。其他两个,我们较少用到,今天,我们看看他们的区别。

 

import java.util.HashSet;
import java.util.Set;


public class HashSetTester {

    public static void main(String[] args) {
        Set<Integer> set = new HashSet<Integer>();
        
        set.add(15);
        set.add(31);
        set.add(12);
        set.add(123);
        set.add(42);
        
        for (Integer i : set) {
            System.out.println(i);
        }
    }

}
View Code

相关文章:

  • 2021-11-30
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2021-10-06
  • 2021-05-29
猜你喜欢
  • 2021-05-21
  • 2021-12-03
  • 2021-08-08
  • 2021-07-27
  • 2021-11-22
相关资源
相似解决方案