Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 01 May 2012 14:17:15 -0500 Date: Tue, 01 May 2012 12:17:17 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Help with program References: <0d9aaec9-10f1-42b5-af5c-f4d563a934ab@e42g2000yqa.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 25 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.201.141 X-Trace: sv3-QG5wg8hYhOMeJEDtadLxcOWGL6vQK0SPm++uRfCo511mHvibuKr0cy6JZ/ZH4hlQ8pT54Gy1nIe/c12!4YbKmUp4rIWDQrz1ucsLui6RPjaqAsZkhunadW8JkAuJJKfvNbhITfjTX+BDm6nN4xecSSEM8Bpv!yiEPzRvmilP3QbyXbsxIdRNPfNz4gwq0IWuqM2O73IGOjss= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2368 Xref: csiph.com comp.lang.java.programmer:14096 On 5/1/2012 12:12 PM, glen herrmannsfeldt wrote: > Patricia Shanahan wrote: >> On 5/1/2012 10:31 AM, mbuenik5@yahoo.com wrote: >>> I need help writing a Java method named swap that takes an integer >>> array and two indexes. The method then swaps the integers at those two >>> indexes. The return type for swap is void. Can anybody write this out? > >> I'm sure any who knows Java beyond the extreme beginner level can write >> it out. Have you considered the possibility that the objective is to get >> you to work out how to do it yourself? That seems likely to me. > > It is usual that you can get help if you have actually tried, > and show what you have and haven't got working. > > For extra challenge, try doing it without any temporary/local variables. I strongly recommend against this, in favor of doing it as simply, cleanly and directly as possible. There are, very rare, situations in which local variables are expensive, and there are some clever tricks for doing without them in various situations. This is not one of those situations. Patricia