Re: Using char[] as key in a HashMap

Attila Szegedi <[email protected]> Wed, 30 Jan 2008 15:54:15 +0100
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
Guilty as charged; apologies.

Attila.

On 2008.01.30., at 14:35, Endre Stølsvik wrote:

> Attila Szegedi wrote:
>> On 2008.01.30., at 12:45, Endre Stølsvik wrote:
>>
>>> However, if you've ended up with the key Strings by using
>>> substring(begin[, end]) on some longer String, you'll carry the  
>>> original
>>> length of the value-array with you.
>>
>> But if you know this is the case, you can get rid of the original
>> storage and have a string that uses the minimal sufficiently sized
>> char[] using the String(String) constructor:
>>
>> String s2 = new String(someHugeString.substring(10000000, 10000003));
>>
>> s2 will have an exactly 3-long underlying char[].
>
> Yes. Read my post when answering to it.
>
> Endre.

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com