Re: Using char[] as key in a HashMap

Endre Stølsvik <[email protected]> Wed, 30 Jan 2008 14:35:56 +0100
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
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