Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!usenet.ukfsn.org!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Inserting In a List Date: Tue, 2 Apr 2013 21:06:47 +0000 (UTC) Organization: UK Free Software Network Lines: 32 Message-ID: References: NNTP-Posting-Host: 84.45.235.129 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: localhost.localdomain 1364936807 18593 84.45.235.129 (2 Apr 2013 21:06:47 GMT) X-Complaints-To: usenet@localhost.localdomain NNTP-Posting-Date: Tue, 2 Apr 2013 21:06:47 +0000 (UTC) User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Xref: csiph.com comp.lang.java.programmer:23193 On Tue, 02 Apr 2013 08:59:52 -0300, Arved Sandstrom wrote: > On 04/02/2013 08:40 AM, Stefan Ram wrote: >> subhabangalore@gmail.com writes: >>> for( File name :folder.listFiles()){ >>> String s1=name.toString(); System.out.println("####"+s1); >>> System.out.print( name ); >>> ArrayList myList = new ArrayList(); >>> myList.add(s1); >>> } >> >> I see two answers in this NG both not mentioning what is sticking >> out like a sore thumb from this code: The line >> >> ArrayList myList = new ArrayList(); >> >> is within the for-loop, while it obviously should appear in front of >> it. (There might be other issues I am not aware of, >> but this one I saw immediately.) >> > You've got a point there. :-) Well, many pairs of eyes in a review is > always better than one. > Its also not clear to me whether the OP is expecting some form of sorted list of filenames. If he is expecting that, it would be best to use a TreeMap rather than an ArrayList to store the filenames. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |