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: Wed, 08 May 2013 17:32:06 +0200 Organization: A noiseless patient Spider Lines: 40 Message-ID: References: <41718873-b1a6-4b97-bbbb-8002c48d4e29@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 8 May 2013 15:28:24 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="8e103db3a4f21801713a9e44848762c0"; logging-data="13927"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4YwD4gCMRuCnDCm2z6RfU" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: Cancel-Lock: sha1:QWFWC0+lVrRB4ajvFIxRkYAyKXk= Xref: csiph.com comp.lang.java.programmer:23927 On 08/05/2013 15:57, lipska the kat allegedly wrote: > On 08/05/13 14:19, Daniele Futtorovic wrote: >> On 08/05/2013 10:06, lipska the kat allegedly wrote: >>> Byte[][] bytes = new Byte[width][height]; >> >> Lipska, mind the difference between Byte and byte. That code above is >> extremely bad advice. > > Why? it's common practice these days to eschew primitives and use > (autoboxing) classes, it's more consistent in OO code and, as I > understand things, post autoboxing, the following two lines are > logically equivalent. > > 1. Byte[][] bytes = new Byte[width][height]; > 2. byte[][] bytes = new byte[width][length] > > The following is perfectly legal given either of the above > > byte b = 127; > bytes[0][0] = b; > Byte c = 126; > bytes[0][1] = c; > Byte d = bytes[0][0]; > byte e = bytes[0][1]; > > I would of course be interested to know what your objection is. Simple: "byte[]" is not a primitive type. "byte" is a primitive type. "byte[]" is a reference type. Along the same lines, you'll be hard pressed to find a Java I/O library that uses Byte[]'s rather than byte[]'s. > Also, I seem to remember being 'told off' for using primitives a while > back ... ho hum. I don't know about that. -- DF.