About Question enthuware.ocpjp.v7.2.1608 :
Posted: Tue Jun 21, 2016 4:40 am
This one caught me off guard/confuses me. I thought initially that both paths p1 & p2 were relative paths because neither start with a root, which is c: on windows and / on unix, right?
But given that assumption, p1.resolve(p2) would have been simply tacking on the relative p2 path onto p1 which would be: \\photos\\vacation\\yellowstone
However given that none of the options had this answer, and knowing that when you pass an absolute path into the argument, it will return the absolute argument, I concluded that \\ means these are absolute paths.
Hence resolve returning the path passed being \\yellowstone which turns into \yellowstone as a String output.
But I see here Paul is saying these paths are not absolute paths but relative paths. This seems to be confirmed, as in my testing, i get null for Paths.get("\\test").getRoot()
I'm very confused here, if these are truly not absolute paths (which getRoot() confirms), why isn't p2 then not simply tacked onto p1?
In the K&B book for OCA/OCP7 prep, there is an example like this:
Path relative = Paths.get("dir");
Path file = Paths.get("Model.pdf");
relative.resolve(file) -> dir/Model.pdf
file.resolve(relative) -> Model.pdf/dir
Both the relative path and the file are relative paths, right? Why do they get tacked on and not in the mock exam question?
Given that "\\test" is a relative path (as I understand from this thread), is it any different from just "test" ?
Cheers!
Dieter
EDIT, in fact on my system, Mac OS X I get this:
Path p1 = Paths.get("\\test");
Path p2 = Paths.get("\\er");
p1.resolve(p2) -> \test/\er
What the.... ?
But given that assumption, p1.resolve(p2) would have been simply tacking on the relative p2 path onto p1 which would be: \\photos\\vacation\\yellowstone
However given that none of the options had this answer, and knowing that when you pass an absolute path into the argument, it will return the absolute argument, I concluded that \\ means these are absolute paths.
Hence resolve returning the path passed being \\yellowstone which turns into \yellowstone as a String output.
But I see here Paul is saying these paths are not absolute paths but relative paths. This seems to be confirmed, as in my testing, i get null for Paths.get("\\test").getRoot()
I'm very confused here, if these are truly not absolute paths (which getRoot() confirms), why isn't p2 then not simply tacked onto p1?
In the K&B book for OCA/OCP7 prep, there is an example like this:
Path relative = Paths.get("dir");
Path file = Paths.get("Model.pdf");
relative.resolve(file) -> dir/Model.pdf
file.resolve(relative) -> Model.pdf/dir
Both the relative path and the file are relative paths, right? Why do they get tacked on and not in the mock exam question?
Given that "\\test" is a relative path (as I understand from this thread), is it any different from just "test" ?
Cheers!
Dieter
EDIT, in fact on my system, Mac OS X I get this:
Path p1 = Paths.get("\\test");
Path p2 = Paths.get("\\er");
p1.resolve(p2) -> \test/\er
What the.... ?