Traverse through map only and using for - each loop for iteration over Map . entrySet ( )
for ( Map . Entry < Integer , Integer > x : m . entrySet ( ) ) if ( x . getValue ( ) == 1 ) System . out . print ( x . getKey ( ) + " ▁ " ) ; }