增强for循环中是将数组s中的值,逐个赋值给name然后打印
所以sysout输出的应该是name,你试试看:
- 01.public static void list2()
- 02. {
- 03. File f=new File("E:\\");
- 04. String[] s=f.list(new FilenameFilter()
- 05. {
- 06.
- 07. public boolean accept(File f,String name)
- 08. {
- 09. return name.endsWith(".html");
- 10. }
- 11. });
- 12. for (String name:s) {
- 13. System.out.println(name);
- 14. }
- 15. }
复制代码 |