I tried the following code as
package collectconstructor;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class QuestionMap {
private int id;
private String name;
private Map<String,String> answers;
public QuestionMap(int id, String name, Map<String, String> answers) {
super();
this.id = id;
this.name = name;
this.answers = answers;
}
public void displayInfo(){
System.out.println("question id:"+id);
System.out.println("question name:"+name);
System.out.println("Answers....");
Set<Entry<String, String>> set=answers.entrySet();
Iterator<Entry<String, String>> itr=set.iterator();
while(itr.hasNext()){
Entry entry= itr.next();
System.out.println("Answer:"+entry.getKey()+" Posted By:"+entry.getValue());
}
}
}
Here in the following code snippet
Set<Entry<String, String>> set=answers.entrySet();
Iterator<Entry<String, String>> itr=set.iterator();
I got the error as the
Multiple markers at this line
The method entrySet() from the type Map refers to the missing type Map$Entry
Entry cannot be resolved to a type
Can anybody explain as Why I am getting this error?
Also I tried importing
import java.util.Map.Entry;
but got same error.. please help!!