Java Path interface and OCPJP7 Exam -
i’m preparing ocpjp7 exam on these days. got 2 questions , accepting answers. first 1 relevant java , other 1 exam achievements.
import java.nio.file.*; class test13{ public static void main(string arfd[]){ path = paths.get("d:\\ocpjp7\\programs\\..\\nio2\\src\\.\\subpath.java"); a=a.normalize(); system.out.println(a); } }
according above code segment, expected output “d:\ocpjp7\programs\nio2\src\subpath.java” not. provides “d:\ocpjp7\nio2\src\subpath.java”
as know normalize() removes redundant elements given path including single dot , double dot. why removes \programs\ element?
in order oracle certified professional, java 7 programmer, have sit 2 exams;
oca -jp (oracle certified associate, java 7 programmer).
java se 7 programmer.
as know can achieve both exams in order. i’m intended first java se 7 programmer , oca.
my question offer oracle, after passing both exams. offering 2 certificates both exams? or 1 certificate both? , else?
as know normalize() removes redundant elements given path including single dot , double dot. why removes \programs\ element?
..
refers the parent directory. in other words, /programs
brings forward , /..
brings back.
the javadoc of path#normalize()
states
if ".." preceded non-".." name both names considered redundant (the process identify such names repeated until no longer applicable).
so \\programs\\..
redundant , removed.
i can't answer second question.
Comments
Post a Comment