View Single Post
  #4 (permalink)  
Old 01-16-2012, 07:07 PM
Arne Vajhøj
Guest
 
Posts: n/a
Default Re: exporting a HashMap

On 1/15/2012 1:22 PM, Lew wrote:
> Arne Vajhøj wrote:
>> Roedy Green wrote:
>>> What is best code to export key-value pairs from a HashMap into some
>>> structure in key-value order.
>>>
>>> One possible way is to extract the keys, sort them, then look up the
>>> values. That strikes me as infantile. Surely there is a better way.
>>>
>>> The best I can think of is to invent a Pair dummy class, extract the
>>> fields from an Entry into the two fields, and sort them in an array.
>>>
>>> Part of the problem is generics and arrays don't mix.

>>
>> Generics and ArrayList mix fine.

>
> And anyway, generics and arrays do mix, just not well. To say merely
> that they don't mix, without the qualifier "well", isinaccurate and
> misleading, and certainly no help to newbies. Better would be to explain
> the limits, why they exist, and what the alternatives are.


Or maybe just use the "well" modifier to keep focus on the
original problem.

Arne


Reply With Quote