Re: Why use Objectg in Equals method?
Eric Sosman wrote:
[**] I understand there's work afoot to "reify" generics,
but as far as I know it hasn't borne fruit yet.
There are reified classes in the Java API now. Static methods in
Collections will make runtime typesafe Collections, Lists, Maps and
Sets. They do it just by storing the class type you specify, and then
testing each operation to make certain it's of the correct type.
But that's an API feature, not a language feature.
static
<E> Collection<E>
checkedCollection(Collection<E> c, Class<E> type)
Returns a dynamically typesafe view of the specified collection.
static
<E> List<E>
checkedList(List<E> list, Class<E> type)
Returns a dynamically typesafe view of the specified list.
static
<K,V> Map<K,V>
checkedMap(Map<K,V> m, Class<K> keyType, Class<V> valueType)
Returns a dynamically typesafe view of the specified map.
static
<E> Set<E>
checkedSet(Set<E> s, Class<E> type)
Returns a dynamically typesafe view of the specified set.
static
<K,V> SortedMap<K,V>
checkedSortedMap(SortedMap<K,V> m, Class<K> keyType, Class<V> valueType)
Returns a dynamically typesafe view of the specified sorted map.
static
<E> SortedSet<E>
checkedSortedSet(SortedSet<E> s, Class<E> type)
Returns a dynamically typesafe view of the specified sorted set.