title: Unnecessary type casting?
body: <p>I am reading this <a href="https://rads.stackoverflow.com/amzn/click/com/0321146530" rel="nofollow noreferrer" rel="nofollow noreferrer">books</a> and there is a code example which seems confusing to me, the confusing part of the fragment I am describing below:</p>
  
  <pre><code>private Hashtable rates = new Hashtable();
  
  void addRate(String from, String to, int rate) {
    rates.put(new Pair(from , to), new Integer(rate)); // Pair is a value object.
  }
  
  int rate(String from, String to) {
    Integer rate = (Integer) rates.get(new Pair(from, to)); // The confusing part.
    return rate.intValue();
  }
  </code></pre>
  
  <p>Why the author needs to type cast while getting the value from <code>HashTable</code> if the value was already of type <code>Integer</code>?</p>