My output is: Input 1 Sam 2 I 1 Am Out Put 2 I 1 Am 1 Sam Process finished with exit code 0 Please note in my code I have enabled System.out.println("Id=" + pair.getValue() + "Name=" + pair.getKey()); for testing purposes.