Path: csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Arrays in java Date: Mon, 09 Jul 2012 11:30:34 -0400 Organization: A noiseless patient Spider Lines: 28 Message-ID: References: <7eb3b37e-612a-4f51-98e5-f39cfd565739@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 9 Jul 2012 15:30:43 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="03ebLEozl+tXCe7JS60Feg"; logging-data="8218"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hqG4e6RTqgBzJnndveg4c" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: <7eb3b37e-612a-4f51-98e5-f39cfd565739@googlegroups.com> Cancel-Lock: sha1:u5C8fQmoS0vCWNkFSZm+atarYUM= Xref: csiph.com comp.lang.java.programmer:15896 On 7/9/2012 10:54 AM, mmc.java wrote: > I am just starting to learn java and wanted to know when creating an array if there is any reason why you choose one of the following over the others or if it is just a styling choice by the developer > > int productIDs[] = {10,20,30}; > int []productIDs = {10,20,30}; > int[] productIDs = {10,20,30}; All are equivalent. The first suggests the code was written by an immigrant from C or C++, the last is the style usually seen in Java, and the middle is just plain ugly. > I did notice the the following will cause a compilation error > []int productIDs = {10,20,30}; //causes an error So will int productIDs = []{10,20,30}; int productIDs = {10,20,30}[]; int productIDs = {[10,20,30]}; productIDs int[] = {10,20,30}; ... and a lot of other random stuff, too. -- Eric Sosman esosman@ieee-dot-org.invalid