Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: How to convert image into Hex 2 Dimensional Array? Date: Wed, 08 May 2013 21:45:13 -0400 Organization: A noiseless patient Spider Lines: 29 Message-ID: References: <41718873-b1a6-4b97-bbbb-8002c48d4e29@googlegroups.com> <518af634$0$32105$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 9 May 2013 01:41:43 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="20841"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18r9yeu+AzOQ5pugXMB4kzn" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: <518af634$0$32105$14726298@news.sunsite.dk> Cancel-Lock: sha1:A3ltW5Ef8jgJsol6Y1ezem7PZbA= Xref: csiph.com comp.lang.java.programmer:23953 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. -- Eric Sosman esosman@comcast-dot-net.invalid