How come arr[0] which contains variable pupils won't work with entrySet()??? enter image description here
Map<String, Integer> pupils = new HashMap<>();
Map<String, Integer> teachers = new HashMap<>();
pupils.put("Alex", 12);
pupils.put("Joe", 11);
teachers.put("Helen", 28);
teachers.put("Michael", 29);
Map[] arr = new Map[2];
arr[0] = pupils;
arr[1] = teachers;
//why this code won't work?
for (Map.Entry<?, ?> me : arr[0].entrySet()){
System.out.println(me.getKey() + " - " + me.getValue());}
//while this code works well
for (Map.Entry<?, ?> me : pupils.entrySet()){
System.out.println(me.getKey() + " - " + me.getValue());}
// and this returns (prints) true!
System.out.println(pupils.entrySet() == arr[0].entrySet());