Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: How to convert image into Hex 2 Dimensional Array? Date: Thu, 09 May 2013 04:09:34 +0200 Organization: A noiseless patient Spider Lines: 48 Message-ID: References: <41718873-b1a6-4b97-bbbb-8002c48d4e29@googlegroups.com> <518af634$0$32105$14726298@news.sunsite.dk> <518b02f9$0$32109$14726298@news.sunsite.dk> <518b040c$0$32109$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 9 May 2013 02:05:51 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="8e103db3a4f21801713a9e44848762c0"; logging-data="26316"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191ZYBkqqK0f2bcNypATtOK" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: Cancel-Lock: sha1:awhoeXMFhwsivaol6Mwhv/8ve7w= Xref: csiph.com comp.lang.java.programmer:23957 On 09/05/2013 04:09, Daniele Futtorovic allegedly wrote: > On 09/05/2013 04:03, Arne Vajhøj allegedly wrote: >> On 5/8/2013 9:59 PM, Arne Vajhøj wrote: >>> On 5/8/2013 9:45 PM, Eric Sosman wrote: >>>> On 5/8/2013 9:04 PM, Arne Vajhøj wrote: >>>>> On 5/8/2013 9:57 AM, lipska the kat wrote: >>>>>> [...] the following two lines are >>>>>> logically equivalent. >>>>>> >>>>>> 1. Byte[][] bytes = new Byte[width][height]; >>>>>> 2. byte[][] bytes = new byte[width][length] >>>>> >>>>> Not at all. >>>>> >>>>> You will eventually end up with 1+width*height and 1 objects >>>>> respectively. >>>> >>>> No; both will generate 1+width objects: >>>> >>>> - One array containing `width' references to other arrays, >>>> >>>> - `width' arrays containing `height' bytes or Byte >>>> references. >>>> >>>> A *really* stupid coder might use Byte[][] *and* populate >>>> the arrays with `new Byte(value)' repeated `width*height' times; >>>> that would produce `1 + width + width*height' objects in all. >>>> Autoboxers would be unlikely to enter that particular trap -- >>>> but even so, a four- to eight-fold memory bloat is not to be >>>> sneezed at. >>> >>> Ooops. >>> >>> 1+width+width*height and 1+width objects. >>> >>> I would still expect the byte version to end up >>> with width*height Byte objects. >>> >>> If there are no null and no reused objects, then >>> I can not see how that can be avoided. >> >> Are you saying that Java will intern so aggressively >> that there will be reused objects? > > Autoboxing will you Byte#valueOf, which returns pooled instances. > *will _use_