Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Delete slot in the middle of an array and shift remaining Date: Fri, 25 Nov 2011 03:21:12 -0800 (PST) Organization: http://groups.google.com Lines: 38 Message-ID: <20684688.629.1322220072927.JavaMail.geo-discussion-forums@prnh1> References: <4ecf7078$0$6582$9b4e6d93@newsspool3.arcor-online.net> Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 173.164.137.214 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1322220073 15933 127.0.0.1 (25 Nov 2011 11:21:13 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 25 Nov 2011 11:21:13 +0000 (UTC) In-Reply-To: <4ecf7078$0$6582$9b4e6d93@newsspool3.arcor-online.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.164.137.214; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10220 Sven Fischer wrote: > Assume I have an array of strings like > > String[] slot = new String[]; > > slot[0] = new String(first"); You should post complete, compilable code in the future. See http://sscce.org/ Here it would have helped you not omit the quotation mark. > slot[1] = new String(second"); If "second" already is a 'String', why do you want to make a new 'String' from it? > slot[2] = new String(third"); > slot[3] = new String(foo"); > slot[4] = new String("bar"); > > Now I want to delete e.g. the third slot and shift all remaining slots 1 slot upwards. > > The result should look like: > > slot[0] = new String(first"); > slot[1] = new String(second"); > slot[2] = new String(foo"); > slot[3] = new String("bar"); > > How can I do this most easily? Use a loop, such as 'while', 'do'...'while' or 'for'. > Is this possible without iteration in a "while" loop? Yes. -- Lew