• HashMap on Java
    Java

    Different ways to traverse a Map in Java

    In this quick article, we’ll have a look at the different ways of iterating through the entries of a Map in Java. Simply put, we can extract the contents of a Map using keySet(), valueSet() or entrySet(). Since those are all sets, similar iteration principles apply to all of them. The Map.entrySet API returns a collection-view of the map, whose elements are from the Map class. The only way to obtain a reference to a single map entry is from the iterator of this collection view. The entry.getKey() returns the key and entry.getValue() returns the corresponding value. Let’s have a look at a few of these. We will use following…

  • Java,  Software Development

    Convert a List to a Set in Java

    Nam eu nisi non quam ultrices lacinia non sit amet urna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pulvinar felis at massa auctor, ac bibendum dolor facilisis. Quisque tristique fringilla convallis. Quisque justo nunc, ornare et turpis et, mollis lobortis lectus. Vivamus blandit nulla et finibus hendrerit. Aliquam at dui id erat ullamcorper fringilla. Aliquam id tellus est. Praesent elementum in nisi quis volutpat. Vestibulum non augue vel dui consequat tempus ut vitae magna. Curabitur ligula orci, facilisis et urna a, rutrum auctor lorem. Proin lacinia sodales diam, vel congue purus feugiat in. Sed ut mattis sem, ac lacinia odio. Donec est leo, tincidunt sit amet tortor nec,…