Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: glen herrmannsfeldt Newsgroups: comp.lang.java.programmer Subject: Re: Curious compiler warning Date: Wed, 11 Jan 2012 02:36:44 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 45 Message-ID: References: NNTP-Posting-Host: H0vc4U5LIRkRHNPyGCs2dA.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org User-Agent: tin/1.9.6-20100522 ("Lochruan") (UNIX) (Linux/2.6.32-5-amd64 (x86_64)) X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11209 Lew wrote: (snip) >> I've got a fairly simply method name foo() that takes two parameters, ints >> called start and finish. During this method, I decrement start and finish >> and then calls another method, bar(), passing the decremented versions of >> start and finish. For some reason, the compiler objects to the statements >> where I decrement start and finish and says "the parameter should not be >> assigned". I'm running Eclipse 3.7.1 with a 1.6.18 JDK. (snip) >> start--; >> finish--; >> bar(start, finish); > What's exactly wrong is that the assignment to the parameters > is thrown away, and does you no good. Well, not thrown away until after the call to bar. Does it actual notice that it isn't used other than the call to bar? How about: while(start+finish>0) { start--; finish--; bar(start, finish); } Would it complain in that case? (snip) > Yes, there's a better way; that one is silly. > public static int foo(int start, int finish) { > /* Other stuff */ > bar(start - 1, finish - 1); That is probably what I would do, but maybe not in the case of a more complicated loop. -- glen