loop inserts the elements and the count of that element of list1 into the hmap
while ( n1 != null ) { if ( hmap . containsKey ( n1 . data ) ) { int val = hmap . get ( n1 . data ) ; hmap . put ( n1 . data , val + 1 ) ; } else { hmap . put ( n1 . data , 1 ) ; } n1 = n1 . next ; }