Type a method that throws and declares a checked exception
Type a method that throws and declares a checked exception
Answer
public String load(String path) throws IOException { return Files.readString(Path.of(path)); }
IOException is checked, so the method must declare throws IOException. Without it, the compiler rejects callers that don't handle it.