hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen O'Malley <o...@yahoo-inc.com>
Subject generic types
Date Fri, 03 Nov 2006 15:52:15 GMT
Hi all,
   I've noticed a couple of people over-specifying the generic  
collections. The general pattern is:

Map<Key,Value> myMap = new HashMap();

where the field is given a type of the general interface with the  
type parameters and the constructor is the specific implementation  
without the type parameters. The assignment works because in Java  
(unlike C++) every T1<T2> extends T1.  The advantage of the general  
interface (eg. "Map" instead of "HashMap") is that if you change the  
implementation later, you only need to change the constructor.


View raw message