TreeMap overview

TreeMap class implements Map interface and its built using tree based data structure Main features of TreeMap TreeMap is similar to any other Map which stores key-value pair Elements in TreeMap will be in sorted order based on keys sorting It contains only unique keys It does not allow NULL key but NULL values are […]

Share this article on

LinkedHashMap with Looping

We can iterate Linkedhashmap using enhanced for loop with keyset() method or by using enhanced for loop with EntrySet() method or by using iterator Case 1 : Enhanced for loop with keyset() Example import java.util.*; public class LinkedHashMapEnhancedForLoopExample { public static void main(String args[]) {   LinkedHashMap<Integer,String>   lhm = new LinkedHashMap<>(); lhm.put(1, “One”); lhm.put(2, […]

Share this article on
< Previous Next >