String类 ends Witho方法 String[] filenames ="caterpillar. jpg cater.gif", bush. jpg",wuwu. jpg",clockmangifi System.out. print("过滤出jpq檔案:"); for (int i=0, i< filenames. length; i++) if(filenames [i]. endsWith(jpg")) System. out. print(filenames[i]+ System. out. println (")i code cho6filefilter iavaString类 • endsWith()方法 String[] filenames = {"caterpillar.jpg", "cater.gif", "bush.jpg", "wuwu.jpg", "clockman.gif"}; System.out.print("过滤出jpg檔案: "); for(int i = 0; i < filenames.length; i++) { if(filenames[i].endsWith("jpg")) { System.out.print(filenames[i] + " "); } } System.out.println(""); code\ch06\FileFilter.java