|
![](/i/fill.gif) |
On 13/03/2012 03:15 PM, Invisible wrote:
> I keep hearing that Java has added generics since I last worked with it.
> I find it amusing that we can now write HashMap<Foo, Bar>, and yet we
> have type signatures like
>
> public Object get(Object key);
>
> Really? I mean, really? Should that not be
>
> public V get(K key);
>
> or similar? Is that not the entire /point/ of generics?
Interesting fact: It seems the latest JDK implements /two/ versions of
the same interface.
public interface Iterator
{
public boolean hasNext();
public Object next();
public void remove();
}
public interface Iterator<E>
{
public boolean hasNext();
public E next();
public void remove();
}
If you accidentally forget to mention the element type, you get the old
version of the interface, with all its type unsafety. Isn't that great?
*sigh*
Post a reply to this message
|
![](/i/fill.gif) |