You must redefine hashCode()and equals(..)your class Pairto indicate that the two objects with the same number are equal. (Better let your IDE generate these 2 methods for you.)
Hashtable hashCode() . Pair, Object , , , Hashtable ( )
, , HashMap Hashtable. .