iterate through hash_set code example
Example 1: iterating over hash, ruby
person = {name: 'bob', height: '6 ft', weight: '160 lbs', hair: 'brown'}
person.each do |key, value|
puts "Bob's #{key} is #{value}"
end
Example 2: hashset in java
Let’s see java hashset example.
import java.util.HashSet;
public class HashSetExample
{
public static void main(String[] args)
{
HashSet<String> hs = new HashSet<>();
hs.add("Banana");
hs.add("Orange");
hs.add("Apple");
hs.add("Pineapple");
hs.add("Mango");
System.out.println(hs);
}
}