Home
Cloud
Big Data
CI
Install
Samples
Java
Ubuntu
Maven
Archive
Java
|
HashSet
Notes
Example
Notes
Unsorted collection
Unordered collection
null elements allowed
Duplicates elements not allowed (hash code)
Example
HashSet<String> hs = new HashSet<>(); hs.add(null); hs.add("aaa"); hs.add("aaa"); hs.add("aaa"); hs.add("bbb"); hs.add("bbb"); hs.add("ccc"); hs.forEach(System.out::println);
Output:
null aaa ccc bbb
© 2010-2022
mti
tek