Why does the program display "null" key and value ?