About Question enthuware.ocpjp.v8.2.1599 :
Posted: Tue Oct 11, 2016 3:07 pm
In this question, we have:
When I'm trying this code out on my Linux machine from IntelliJ, I get the following result:
However, you mark the answer "java.lang.IllegalArgumentException will be thrown" as the correct one with the explanation "Note that if one path has a root (for example, if a path starts with a // or c:) and the other does not, relativize cannot work and it will throw an IllegalArgumentException."
From my point of view, the path "\\index.html" does not contain a root element. Only if I change this path to "/index.html" than I get this Exception.
Code: Select all
Path p1 = Paths.get("photos\\goa");
Path p2 = Paths.get("\\index.html");
Path p3 = p1.relativize(p2);
System.out.println(p3);
Code: Select all
../\index.html
From my point of view, the path "\\index.html" does not contain a root element. Only if I change this path to "/index.html" than I get this Exception.