HashMap model1 = wordobject.getMap();
Set sample = model1.keySet();
Iterator it = sample.iterator();
==
Can you please explain me the above 3 lines?
I see that we are trying to get the hash table from the object and get it assigned to the HashMapmodel1.
1) what is keyset?
2) what does .iterator do?
You are declaring a typical Java HashMap in the first line (a little obvious). You usually construct a HashMap using generics for key value pairs:
HashMap<K,V>The Java API HashMap class allows you to get a set of the keys used for the HashMap. The keySet() method returns a
Set<K>.An iterator allows you to iterate through the set calling methods like next() and hasNext(). It is a way to traverse the set sequentially.