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 07:55:05 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 37 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:11218 Novice wrote: (snip) >>> start--; >>> finish--; >>> bar(start, finish); (snip, someone wrote) >> What's exactly wrong is that the assignment to the parameters is >> thrown away, and does you no good. > How so? My original code says - in my opinion - "thank you very much for > the value but we need to adjust it a little by subtracting one, aside > from that, it's perfect". But, as previously noted, why not bar(start-1, finish-1)? Now, if you are using the new values 10 times, or maybe even just two, then it is more obvious to me. > It's not like we're changing start to an > arbitrary value like 0 or 5 billion regardless of the original value. The > code in this class basically just does String functions to count the > number of occurrences of a string in another string but I'm assuming that > the user will consider the initial character of the string being searched > as '1' while Java's methods are all 0-based. I'm just subtracting one to > bring the user's view of the situation in line with Java's view. > I'm just wondering why the compiler is so offended by "start--".... Personally, there are a few things that I find compilers warning about that bother me. In this case, there is a claim that the test is optional, and that the default is off. I wouldn't turn it on, but others might. -- glen