I have an idea... Just bouncing it off the list blindly for a
confirmation / sanity check.
Thanks!
///////
package java.util;
import java.util.Map.Entry;
public interface Map<K extends Object, V extends Object> {
public static interface Entry<K extends Object, V extends Object> {
public K getKey();
public V getValue();
public V setValue(V v);
public boolean equals(Object o);
public int hashCode();
}
public int size();
public boolean isEmpty();
public boolean containsKey(Object o);
public boolean containsValue(Object o);
public V get(Object o);
public V put(K k, V v);
public V remove(Object o);
public void putAll(Map<? extends K, ? extends V> map);
public void clear();
public Set<K> keySet();
public Collection<V> values();
public Set<Entry<K, V>> entrySet();
public boolean equals(Object o);
public int hashCode();
}
--
=================================================================
= Management is doing things right; =
= Leadership is doing the right things. - Peter Drucker =
=================================================================
Are u asking why the get method accepts arg of Object insted of
K? Please be more specific.
I'm not really sure, but I'll bet that it is because the key compared by memory address, making it completely unnecessary, and possibly excessive to have a type definition. it might also save the compiler from needing to perform type erasure. If you are iterating over a keyList, then I could see why you would want to use generics. if you are iterating over a keyList that is of a type you have control of, and you really don't want to so something like Foo foo = (Foo)iter.next(); then you could possibly override the .equals() method to serve your purpose. of course you would only want to do this unless you are not isolating by memory address.
Ryan McCullough
please summarize your opinion, that thing has 4 different points of view
Ryan McCullough
(816) 2000-816 - Home & Mobile
Uniformly, methods of the Java Collections Framework (and the Google Collections Library too) never restrict the types of their parameters except when it's necessary to prevent the collection from getting broken.
</quote>
--David
Please para-phrase your opinion in the email thread, or be brandeds a hard headed jerk. Not everyone here is able to view this link.
On Oct 29, 2009 10:25 PM, "Kevin Shekleton" <kevin.s...@gmail.com> wrote:
Take a look at the accepted answer, which also has the most up votes.
On Thu, Oct 29, 2009 at 5:32 PM, Ryan McCullough <rhea...@gmail.com> wrote: > > please summarize ...