Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: thinbluernime Newsgroups: comp.lang.java.programmer Subject: Re: A question about a solution from codingbat.com Date: Fri, 25 Jul 2014 03:52:03 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 17 Message-ID: References: <07898d55-9606-44a7-8298-8f5f1c9094c6@googlegroups.com> <53d1a920$0$291$14726298@news.sunsite.dk> NNTP-Posting-Host: i+hccjf+IDuaX49PUP4Bpw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.10 (MacIntel) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:29293 On Thu, 24 Jul 2014 18:39:12 -0700, cdalten wrote: > I don't think your code and his code are doing exactly the same. I would > expect different results from "axbxxc". > > Why does this produce different results? This version shouldn't: boolean doubleX(String str) { for(int i = 0; i < str.length() - 1; i++) { if(str.charAt(i) == 'x'){ return str.charAt(i+1) == 'x'; } }//end for return false; }