以下示例显示了通过创建文件过滤器在目录中查找特定文件的方法。以下示例显示所有文件名以“b”开头的文件。示例实时演示import java.io.*; public class Main { public static void main(String[] args) { File dir = new File("C:"); FilenameFilter filter = new FilenameFilter() { public boolean accept (File dir, String name) { return name.startsWith("b"); } }; String[] children = ... 阅读更多
println() 通过写入行分隔符字符串来终止当前行。print() 方法只打印给定的内容。示例实时演示public class Sample { public static void main(String args[]) { System.out.println("Hello"); System.out.println("how are you"); System.out.print("Hello"); System.out.print("how are you"); } }输出Hello how are you Hellohow are you