import java.io.IOException;
import java.nio.file.*;
public class Rose {
public void tendGarden(Path p) throws IOException {
Files.walk(p,1)
.map(q -> q.toRealPath())
.forEach(System.out::println);
}
public static void main(String[] thorns) throws IOException {
new Rose().tendGarden(Paths.get(thorns[0]));
}
}
The above code doesn't compile because of q.toRealPath(), instead throws java: unreported exception java.io.IOException; must be caught or declared to be thrown. while I am already throwing it to main method which is throwing it to java environment. Somewhere I read that because of using interface as a method signature I am not able to use throws. Can someone please explain why?