Category Archives: HashSet

Convert HashSet of String objects to ArrayList in java (example)

Given a HashSet containing String objects in java. HashSet will be containing Sport’s name. Convert HashSet <String> to ArrayList<String> in java. We will use the constructor of ArrayList to achieve the conversion. Program – convert HashSet of Strings to ArrayList in java package org.learn.collection.set.hset; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; public class DemoHashSetToArrayList { public… Read More »

Iterate/loop elements/string objects of HashSet collection in java8 (example)

HashSet class implements the Set interface, backed by a hash table. HashSet contains the unique elements. HashSet does not contains any duplicate keys HashSet can have only 1 null key. HashSet does not maintained the order of elements or keys. HashSet is UnSynchronized and not thread safe. Given a HashSet collection having String objects in java.… Read More »