Re: Using char[] as key in a HashMap
Attila Szegedi <[email protected]> Wed, 30 Jan 2008 13:23:02 +0100
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
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[]. Attila. -- home: http://www.szegedi.org weblog: http://constc.blogspot.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com